Skip to content

Instantly share code, notes, and snippets.

@vegarringdal
Last active December 6, 2020 14:41
Show Gist options
  • Save vegarringdal/6adaffd6b28f999af87a3491237f0f00 to your computer and use it in GitHub Desktop.
Save vegarringdal/6adaffd6b28f999af87a3491237f0f00 to your computer and use it in GitHub Desktop.
DOCKER
version: '3.5'
# docker with pgadmin/postgres/nodejs
# endable docker to start with OS
# - sudo systemctl enable docker
# to run:
# sudo docker-compose up -d
# remove the -d to get messages from docker, do not run in vscode
# todo add redis memory db for users etc
services:
postgres:
container_name: postgres_container
image: postgres:11.1
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
POSTGRES_DB: ${POSTGRES_DB:-postgres}
PGDATA: /data/postgres
volumes:
- ./postgres:/data/postgres
ports:
- "${POSTGRES_PORT:-5432}:5432"
networks:
- ${POSTGRES_HOST:-postgres}
restart: always
pgadmin:
container_name: pgadmin_container
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:[email protected]}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-postgres}
volumes:
- ./pgadmin:/root/.pgadmin
ports:
- "${PGADMIN_PORT:-5050}:80"
networks:
- postgres
restart: always
node:
image: "node:11"
user: "node"
working_dir: /home/node/app
depends_on:
- postgres
environment:
NODE_ENV: ${NODE_ENV:-production}
POSTGRES_HOST: ${POSTGRES_HOST:-postgres}
POSTGRES_DB: ${NODE_ENV:-postgres}
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
POSTGRES_PORT: ${POSTGRES_PORT:-5432}
volumes:
- ./:/home/node/app
ports:
- "8081:8081"
expose:
- "8081"
networks:
- ${POSTGRES_HOST:-postgres}
command: "npm start"
restart: always
networks:
postgres:
driver: bridge
volumes:
postgres:
pgadmin:
# docker and pgadmin v1
# "sudo docker-compose up -d" to run
version: '3.5'
services:
postgres:
container_name: postgres_container
image: postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
PGDATA: /data/postgres
volumes:
- ./postgres:/data/postgres
ports:
- "5432:5432"
networks:
- postgres
restart: unless-stopped
pgadmin:
container_name: pgadmin_container
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:[email protected]}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-postgres}
volumes:
- ./pgadmin:/root/.pgadmin
ports:
- "${PGADMIN_PORT:-5050}:80"
networks:
- postgres
restart: unless-stopped
networks:
postgres:
driver: bridge
volumes:
postgres:
pgadmin:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment