Newer
Older

Lukáš Kratochvíl
committed
server:
container_name: server
image: server:1.0.0
build:
context: ./backend
dockerfile: Dockerfile
# change target in order to run in different environment ('development' or 'production' environment, see ./backend/Dockerfile)

Lukáš Kratochvíl
committed
target: development

Lukáš Kratochvíl
committed
ports:

Lukáš Kratochvíl
committed
- 127.0.0.1:${SERVER_PORT}:${SERVER_PORT}
networks:
- backend-network

Lukáš Kratochvíl
committed
volumes:
# changes in host's ./backend directory will be propagated to the container
- ./backend:/usr/src/app

Lukáš Kratochvíl
committed
# this will let us add packages during development without rebuilding the image
# - we then need to install added packages (run 'npm i') inside the container in the folder '/usr/src'
- ./backend/package.json:/usr/src/package.json
- ./backend/package-lock.json:/usr/src/package-lock.json

Lukáš Kratochvíl
committed
# this prevents our host files from overriding container's node_modules

Lukáš Kratochvíl
committed
# – some packages may be platform specific so we always want to run 'npm i' in the container when new package is added
- exclude-server:/usr/src/app/node_modules/
environment:
- PORT=${SERVER_PORT}

Lukáš Kratochvíl
committed
- DATABASE_URL=${DATABASE_URL}

Lukáš Kratochvíl
committed
restart: always

Lukáš Kratochvíl
committed
postgres:
container_name: postgres
image: postgres:14.3-alpine
ports:
- 127.0.0.1:${DB_PORT}:${DB_PORT}

Lukáš Kratochvíl
committed
networks:

Lukáš Kratochvíl
committed
volumes:
- ./backend/database-storage:/var/lib/postgresql/data

Lukáš Kratochvíl
committed
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME}

Lukáš Kratochvíl
committed
PGPORT: ${DB_PORT}

Lukáš Kratochvíl
committed
restart: always
adminer:
container_name: adminer
image: adminer:4.8.1
ports:
- 127.0.0.1:${ADMINER_PORT}:${ADMINER_PORT}

Lukáš Kratochvíl
committed
networks:
- backend-network

Lukáš Kratochvíl
committed
environment:
ADMINER_DESIGN: nette
restart: always
depends_on:

Lukáš Kratochvíl
committed
nginx:
container_name: nginx
image: nginx:1.21.6-alpine
ports:
- 127.0.0.1:${NGINX_PORT}:${NGINX_PORT}

Lukáš Kratochvíl
committed
networks:
- backend-network

Lukáš Kratochvíl
committed
- frontend-network
volumes:
- ./nginx/templates:/etc/nginx/templates
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
environment:
- NGINX_PORT=${NGINX_PORT}
- SERVER_PORT=${SERVER_PORT}
restart: always
depends_on:
- server
- postgres
client:
container_name: client
image: client:1.0.0
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- 127.0.0.1:${CLIENT_PORT}:${CLIENT_PORT}

Lukáš Kratochvíl
committed
networks:
- frontend-network
volumes:
# changes in host's ./frontend directory will be propagated to the container
- ./frontend:/usr/src/app
# this will let us add packages during development without rebuilding the image
# - we then need to install added packages (run 'npm i') inside the container in the folder '/usr/src'
- ./frontend/package.json:/usr/src/package.json
- ./frontend/package-lock.json:/usr/src/package-lock.json
# this prevents our host files from overriding container's node_modules

Lukáš Kratochvíl
committed
# – some packages may be platform specific so we always want to run 'npm i' in the container when new package is added
- exclude-client:/usr/src/app/node_modules/
environment:
- PORT=${CLIENT_PORT}
# all the traffic goes through Nginx server
- VITE_SERVER_PORT=${NGINX_PORT}
networks:
backend-network:

Lukáš Kratochvíl
committed
frontend-network:

Lukáš Kratochvíl
committed
volumes:
database-storage:
exclude-server:
exclude-client: