Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add production target to api #95

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: ./api/
target: production
file: ./api/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
Expand Down
34 changes: 22 additions & 12 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,42 @@ WORKDIR /app

COPY . .

FROM node:18-alpine AS installer
RUN npm update -g npm

RUN npm i --verbose --maxsockets 6

RUN npm run build


FROM node:18-alpine AS development

WORKDIR /app

COPY --from=builder /app/package*.json ./
COPY --from=builder /app/ .

COPY --from=builder /app/merge-extensions-deps.js ./
ENV NODE_ENV=development

COPY --from=builder /app/src/extensions ./src/extensions
RUN npm install

COPY --from=builder /app/patches ./patches

RUN npm update -g npm
EXPOSE 3000

RUN npm config set registry https://registry.npmjs.com/
CMD ["npm", "run", "start:debug"]

RUN npm i --verbose --maxsockets 6

FROM node:18-alpine AS runner
FROM node:18-alpine AS production

WORKDIR /app

COPY --from=installer /app/ .
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/ .
Emnaghz marked this conversation as resolved.
Show resolved Hide resolved
COPY --from=builder /app/node_modules ./node_modules

ENV NODE_ENV=production

COPY . .
# Run npm prune to remove dev dependencies
RUN npm prune --production

EXPOSE 3000

CMD [ "npm", "run" , "start:dev" ]
CMD ["npm", "run", "start:prod"]
3 changes: 2 additions & 1 deletion docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
database-init:
build:
context: ../api
target: development
pull_policy: build
volumes:
- ../api/src:/app/src
Expand All @@ -13,6 +14,7 @@ services:
api:
build:
context: ../api
target: development
pull_policy: build
ports:
- ${API_PORT}:3000
Expand All @@ -21,7 +23,6 @@ services:
- ../api/src:/app/src
- ../api/migrations:/app/migrations
#- ../api/node_modules:/app/node_modules
command: ["npm", "run", "start:debug"]

mongo-express:
container_name: mongoUi
Expand Down