Created
September 30, 2022 15:07
-
-
Save dmsysop/95e7d3e2661835575a2cb6241ff91e6d to your computer and use it in GitHub Desktop.
Dockerfile and docker-compose NestJS + PostgreSQL application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.8' | |
services: | |
# nestjs: | |
# container_name: nestjs_api | |
# image: nestjs-api-dev:1.0.0 | |
# build: | |
# context: . | |
# target: development | |
# dockerfile: ./Dockerfile | |
# command: npm run start:debug | |
# ports: | |
# - 3000:3000 | |
# - 9229:9229 | |
# networks: | |
# - nesjs-network | |
# volumes: | |
# - .:/usr/src/app | |
# - /usr/src/app/node_modules | |
# restart: unless-stopped | |
# depends_on: | |
# - pgsql | |
pgsql: | |
image: postgres:alpine | |
ports: | |
- '5432:5432' | |
container_name: 'pgsql' | |
restart: always | |
volumes: | |
- pg-data:/var/lib/postgresql/data | |
environment: | |
POSTGRES_USER: pguser | |
POSTGRES_PASSWORD: pgpassword | |
adminer: | |
image: adminer | |
restart: always | |
depends_on: | |
- pgsql | |
ports: | |
- 8080:8080 | |
volumes: | |
pg-data: | |
networks: | |
nesjs-network: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:12.19.0-alpine3.9 AS development | |
WORKDIR /usr/src/app | |
COPY package*.json ./ | |
RUN npm install glob rimraf | |
RUN npm install --only=development | |
COPY . . | |
RUN npm run build | |
FROM node:12.19.0-alpine3.9 as production | |
ARG NODE_ENV=production | |
ENV NODE_ENV=${NODE_ENV} | |
WORKDIR /usr/src/app | |
COPY package*.json ./ | |
RUN npm install --only=production | |
COPY . . | |
COPY --from=development /usr/src/app/dist ./dist | |
CMD ["node", "dist/main"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment