mirror of
https://github.com/sergeyyarkov/node-docker-example.git
synced 2026-10-11 10:19:41 +03:00
feat: added docker compose node+docker
This commit is contained in:
parent
cff329ebdb
commit
394e530643
@ -13,13 +13,6 @@ RUN npm ci --only-production
|
||||
|
||||
FROM base as production
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV PG_HOST=localhost
|
||||
ENV PG_PORT=5432
|
||||
ENV PG_USER=postgres
|
||||
ENV PG_PASSWORD=1234
|
||||
ENV PG_DB_NAME=articles
|
||||
|
||||
COPY --chown=node:node ./package*.json ./
|
||||
RUN npm ci --production
|
||||
COPY --chown=node:node . .
|
||||
|
||||
38
docker-compose.yml
Normal file
38
docker-compose.yml
Normal file
@ -0,0 +1,38 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
backend:
|
||||
container_name: node-docker-example
|
||||
restart: always
|
||||
build:
|
||||
context: .
|
||||
target: production
|
||||
ports:
|
||||
- ${PORT}:${PORT}
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PG_HOST=postgres
|
||||
- PG_PORT=5432
|
||||
- PG_USER=postgres
|
||||
- PG_PASSWORD=1234
|
||||
- PG_DB_NAME=articles
|
||||
volumes:
|
||||
- ./:/home/node/app
|
||||
command: dumb-init node index.js
|
||||
depends_on:
|
||||
- postgres
|
||||
postgres:
|
||||
container_name: postgres
|
||||
image: postgres:14
|
||||
volumes:
|
||||
- postgres_volume:/var/lib/postgresql/data
|
||||
environment:
|
||||
POSTGRES_USER: ${PG_USER}
|
||||
POSTGRES_PASSWORD: ${PG_PASSWORD}
|
||||
POSTGRES_DB: ${PG_DB_NAME}
|
||||
ports:
|
||||
- 5432:5432
|
||||
volumes:
|
||||
postgres_volume:
|
||||
Loading…
x
Reference in New Issue
Block a user