From e2f9986f1a13c1cf9df0e25d46dfd6fa7f61747b Mon Sep 17 00:00:00 2001 From: John DeAngelis Date: Thu, 14 Nov 2024 09:42:35 -0500 Subject: [PATCH] build: add back compose for initial data Signed-off-by: John DeAngelis --- docker-compose.initial.yml | 90 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 docker-compose.initial.yml diff --git a/docker-compose.initial.yml b/docker-compose.initial.yml new file mode 100644 index 0000000000..4012c25d04 --- /dev/null +++ b/docker-compose.initial.yml @@ -0,0 +1,90 @@ +services: + + db: + image: "postgres:16" + container_name: ops-db + security_opt: + - no-new-privileges:true # Resolve semgrep https://sg.run/0n8q + environment: + - POSTGRES_PASSWORD=local_password + read_only: true # Resolve semgrep https://sg.run/e4JE + tmpfs: /var/run/postgresql/ + volumes: + - ./backend/data_tools/ops_db_sql_init:/docker-entrypoint-initdb.d + ports: + - "5432:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 5s + timeout: 5s + retries: 5 + + data-import: + build: + context: ./backend/ + dockerfile: Dockerfile.data-tools + container_name: ops-data-import + environment: + - ENV=local + - SQLALCHEMY_DATABASE_URI=postgresql://ops:ops@db:5432/postgres + command: /bin/sh -c "./data_tools/scripts/initial_data.sh" + volumes: + - ./backend/ops_api:/home/app/ops_api + depends_on: + db: + condition: service_healthy + + disable-users: + build: + context: ./backend/ + dockerfile: Dockerfile.data-tools + container_name: disable-users + environment: + - ENV=local + - SQLALCHEMY_DATABASE_URI=postgresql://ops:ops@db:5432/postgres + command: ["/home/app/.venv/bin/python", "./data_tools/src/disable_users/disable_users.py"] + depends_on: + db: + condition: service_healthy + data-import: + condition: service_completed_successfully + + backend: + build: + context: ./backend/ + dockerfile: Dockerfile.ops-api + container_name: ops-backend + ports: + - "8080:8080" + command: /bin/sh -c " . .venv/bin/activate && python -m flask run --debug --host=0.0.0.0 --port=8080" + environment: + - JWT_PRIVATE_KEY + - JWT_PUBLIC_KEY + - OPS_CONFIG=environment/local/container.py + volumes: + - ./backend/ops_api/ops:/home/app/ops_api/ops + depends_on: + db: + condition: service_healthy + data-import: + condition: service_completed_successfully + healthcheck: + test: [ "CMD", "curl", "-f", "http://localhost:8080" ] + interval: 10s + timeout: 10s + retries: 10 + + frontend: + build: + context: ./frontend/ + dockerfile: Dockerfile + container_name: ops-frontend + environment: + - REACT_APP_BACKEND_DOMAIN=http://localhost:8080 + - VITE_BACKEND_DOMAIN=http://localhost:8080 + ports: + - "3000:3000" + depends_on: + - backend + volumes: + - ./frontend/src:/home/app/src