From c13d56fb4822127a3a73769804b84cf86dd70dd3 Mon Sep 17 00:00:00 2001 From: Parisa Samimi Date: Thu, 21 Mar 2024 14:35:04 +0100 Subject: [PATCH] build --- backend/Dockerfile | 9 --------- compose.yaml | 1 + frontend/Dockerfile | 19 +++++++++++++------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 70ae6ac6..6afeb70c 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,20 +1,11 @@ FROM golang:1.21 as build - WORKDIR /dist COPY . . - -# Adjust the ARCH if needed - eg amd64 or arm64v8 ENV GOARCH=amd64 CGO_ENABLED=0 - RUN go mod download - -# Build the binary RUN go build -v -o app ./main.go && chmod +x app FROM alpine:latest as production - COPY --from=build /dist /usr/bin - EXPOSE 80 - CMD ["app", "serve", "-port=80"] \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index 3ea0e597..71cd502c 100644 --- a/compose.yaml +++ b/compose.yaml @@ -5,6 +5,7 @@ services: build: context: ./frontend dockerfile: Dockerfile + target: develop depends_on: - app ports: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 3d06f6d7..87c544c0 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,11 +1,18 @@ -FROM node:21.6-alpine3.18 - -WORKDIR /app - +FROM node:21.6-alpine3.18 AS base +WORKDIR /opt/app COPY . . - RUN npm install +FROM base AS develop EXPOSE 3000 +CMD ["npm", "run", "dev", '--host'] -CMD npm run dev --host \ No newline at end of file +FROM base as build +RUN npm run build + +FROM base as production +WORKDIR /opt/app +COPY --from=build /opt/app/.output . +ENV NODE_ENV=production +EXPOSE 3000 +CMD ["node", "server/index.mjs"]