aboutsummaryrefslogtreecommitdiffstats
path: root/docker-compose.yml
blob: d2192f5cce25c5f9cee168bfa7df3c10d920112c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
### Docker compose setup file
# This file can be used to quickly set up a development server
# with code auto-reloading and automatic execution of migrations.
#
## Note
# This file is not intended to be used for production.
# The "migrate and server" script will automatically apply migrations
# and additionally use the Django development server which is
# unsuitable for production.

version: "3.8"
services:
  postgres:
    image: postgres:15-alpine
    ports:
      - "7777:5432"
    environment:
      POSTGRES_DB: pysite
      POSTGRES_PASSWORD: pysite
      POSTGRES_USER: pysite
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U pysite"]
      interval: 2s
      timeout: 1s
      retries: 5
    volumes:
      - ./postgres/init.sql:/docker-entrypoint-initdb.d/init.sql

  web:
    build:
      context: .
      dockerfile: Dockerfile
    command: ["python", "manage.py", "run"]
    networks:
      default:
        aliases:
          - api.web
          - admin.web
          - staff.web
    ports:
      - "8000:8000"
    depends_on:
      postgres:
        condition: service_healthy
    tty: true
    volumes:
      - .:/app:ro
      - staticfiles:/var/www/static
    environment:
      DATABASE_URL: postgres://pysite:pysite@postgres:5432/pysite
      METRICITY_DB_URL: postgres://pysite:pysite@postgres:5432/metricity
      SECRET_KEY: suitable-for-development-only
      STATIC_ROOT: /var/www/static
      DEBUG: 1

volumes:
  staticfiles: