Skip to content

Commit

Permalink
new feat: docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachid F committed Oct 31, 2023
1 parent 160cfab commit 7ce9a6d
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ENV=dev

POSTGRES_USER: my_user
POSTGRES_PASSWORD: my_password
POSTGRES_DB: panora_db
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/node_modules/
**/dist/
node_modules
pg_data/
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:
postgres:
image: postgres:14.6
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "5432:5432"
volumes:
- ./pg_data:/var/lib/postgresql/data
networks:
- my_network
api:
build: ./packages/api
environment:
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@host.docker.internal:5432/${POSTGRES_DB}?ssl=false
restart:
unless-stopped
ports:
- 3000:3000
depends_on:
- postgres

networks:
my_network:
driver: bridge
5 changes: 5 additions & 0 deletions packages/api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.git
.gitignore
*.md
dist
22 changes: 22 additions & 0 deletions packages/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:16-alpine AS base

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
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 3000

CMD [ "pnpm", "run start" ]

0 comments on commit 7ce9a6d

Please sign in to comment.