Skip to content

Commit

Permalink
api docker + project docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeh committed May 18, 2024
1 parent 6b4b4b8 commit 9a2abef
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
32 changes: 32 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# TODO: Consider using 2 steps, one for building, then copy the build artifacts to a new image for running. Talk with FE team about this.

FROM node:22.2.0-alpine


WORKDIR /app


COPY package.json pnpm-workspace.yaml pnpm-lock.yaml tsconfig.json ./
COPY api/package.json api/tsconfig.json ./api/
COPY shared/package.json shared/tsconfig.json ./shared/

# Install jq to extract the version of pnpm from the package.json
RUN apk add --no-cache jq

# Extract the version of pnpm from the package.json and install it
RUN export PNPM_VERSION=$(jq -r '.packageManager' /app/package.json | cut -d '@' -f 2) && \
npm install -g pnpm@$PNPM_VERSION

COPY api ./api
COPY shared ./shared

RUN pnpm run api:deps


RUN pnpm api:build


EXPOSE 4000


CMD ["pnpm", "api:prod"]
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3.8'

services:
api:
build:
context: .
dockerfile: api/Dockerfile
ports:
- "4000:4000"
environment:
- NODE_ENV=production
networks:
- 4-growth-docker-network

client:
build:
context: .
dockerfile: client/Dockerfile
ports:
- "3000:3000"
environment:
- NODE_ENV=production
networks:
- 4-growth-docker-network


networks:
4-growth-docker-network:
driver: bridge

0 comments on commit 9a2abef

Please sign in to comment.