Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

chore: add dockerfile for express server #23

Merged
merged 1 commit into from
Nov 14, 2023
Merged
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
9 changes: 8 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
container_name: rss-graphql-db
build:
context: .
dockerfile: db.Dockerfile
volumes:
- rss-graphql-db-data:/var/lib/postgresql/data
ports:
Expand All @@ -14,6 +15,12 @@ services:
POSTGRES_PASSWORD: ${PASSWORD}
POSTGRES_DB: rss-graphql-db
restart: always

server:
container_name: rss-graphql-server
build:
context: .
dockerfile: server.Dockerfile
ports:
- 4000:4000
volumes:
rss-graphql-db-data:
File renamed without changes.
25 changes: 25 additions & 0 deletions server.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# REF: https://pnpm.io/docker

FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

# this is necessary in prisma
RUN apt-get update -y && apt-get install -y openssl

RUN corepack enable
COPY . /app
WORKDIR /app

FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
EXPOSE 4000
CMD [ "pnpm", "start" ]