From 7ab1c0b9d1ce7a3a47033b0307c2c35158365926 Mon Sep 17 00:00:00 2001 From: Brieuc Dubois Date: Fri, 26 Jan 2024 16:16:48 +0100 Subject: [PATCH] Fix combined dockerfile --- Dockerfile | 34 ++++++++++++------- frontend/run.sh | 4 +-- frontend/src-tauri/tauri.conf.json | 2 +- .../src/lib/components/project/Sidebar.svelte | 2 +- run.sh | 6 ++-- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 39f8c68..0767f82 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,33 +1,41 @@ +#Frontend FROM node:20 as frontend-builder + WORKDIR /app -COPY frontend/. . + +COPY frontend/package.json . +COPY frontend/package-lock.json . RUN npm install + +COPY frontend . RUN npm run build +# Backend FROM golang:1.21.5 as backend-builder WORKDIR /app COPY backend/. . RUN CGO_ENABLED=1 GOOS=linux go build -o main +# Combined FROM debian:stable-slim WORKDIR /app -COPY --from=frontend-builder /app /app/frontend +RUN apt-get update && \ + apt-get install -y nginx + +COPY --from=frontend-builder /app/build /var/www/html COPY --from=backend-builder /app/main /app/backend/main -RUN apt-get update && apt-get install -y curl -RUN curl -sL https://deb.nodesource.com/setup_20.x | bash - -RUN apt-get install -y nodejs - -VOLUME /data - -EXPOSE 4173 3000 - -ENV DB_PATH=/data/db.sqlite -ENV PUBLIC_BACKEND_URL=http://localhost:3000 - COPY run.sh /app/run.sh RUN chmod +x /app/run.sh +VOLUME /data + +EXPOSE 80 3000 + +ENV DB_PATH=/data/db.sqlite +ENV PUBLIC_BACKEND_URL=http://localhost:3000 + + CMD ["/app/run.sh"] diff --git a/frontend/run.sh b/frontend/run.sh index b8ce412..ba2a682 100644 --- a/frontend/run.sh +++ b/frontend/run.sh @@ -2,7 +2,7 @@ PUBLIC_BACKEND_URL=${PUBLIC_BACKEND_URL:-http://localhost:3000} PUBLIC_BACKEND_WSURL=${PUBLIC_BACKEND_WSURL:-${PUBLIC_BACKEND_URL/http:/ws:}} PUBLIC_BACKEND_WSURL=${PUBLIC_BACKEND_WSURL/https:/wss:} -find /usr/share/nginx/html -type f -exec sed -i "s|http://localhost:3000|$PUBLIC_BACKEND_URL|g" {} + -find /usr/share/nginx/html -type f -exec sed -i "s|ws://localhost:3000|$PUBLIC_BACKEND_WSURL|g" {} + +find /var/www/html -type f -exec sed -i "s|http://localhost:3000|$PUBLIC_BACKEND_URL|g" {} + +find /var/www/html -type f -exec sed -i "s|ws://localhost:3000|$PUBLIC_BACKEND_WSURL|g" {} + nginx -g 'daemon off;' diff --git a/frontend/src-tauri/tauri.conf.json b/frontend/src-tauri/tauri.conf.json index 04e1be1..cb896a3 100644 --- a/frontend/src-tauri/tauri.conf.json +++ b/frontend/src-tauri/tauri.conf.json @@ -9,7 +9,7 @@ }, "package": { "productName": "Focus-Desktop", - "version": "0.4.0" + "version": "0.4.1" }, "tauri": { "allowlist": { diff --git a/frontend/src/lib/components/project/Sidebar.svelte b/frontend/src/lib/components/project/Sidebar.svelte index f5683bb..639c50c 100644 --- a/frontend/src/lib/components/project/Sidebar.svelte +++ b/frontend/src/lib/components/project/Sidebar.svelte @@ -46,7 +46,7 @@
Focus. - v0.4.0 + v0.4.1
diff --git a/run.sh b/run.sh index 020a244..ec0ae19 100644 --- a/run.sh +++ b/run.sh @@ -4,10 +4,10 @@ PUBLIC_BACKEND_URL=${PUBLIC_BACKEND_URL:-http://localhost:3000} PUBLIC_BACKEND_WSURL=${PUBLIC_BACKEND_WSURL:-${PUBLIC_BACKEND_URL/http:/ws:}} PUBLIC_BACKEND_WSURL=${PUBLIC_BACKEND_WSURL/https:/wss:} -find frontend -type f -exec sed -i "s|http://localhost:3000|$PUBLIC_BACKEND_URL|g" {} + -find frontend -type f -exec sed -i "s|ws://localhost:3000|$PUBLIC_BACKEND_WSURL|g" {} + +find /usr/share/nginx/html -type f -exec sed -i "s|http://localhost:3000|$PUBLIC_BACKEND_URL|g" {} + +find /usr/share/nginx/html -type f -exec sed -i "s|ws://localhost:3000|$PUBLIC_BACKEND_WSURL|g" {} + -cd frontend && npm run preview -- --port 4173 --host 0.0.0.0 & +nginx -g 'daemon off;' & cd backend && ./main & wait -n \ No newline at end of file