-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
63 lines (56 loc) · 2.57 KB
/
docker-compose.yml
File metadata and controls
63 lines (56 loc) · 2.57 KB
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
58
59
60
61
62
63
# Specifies the version of the Docker Compose file format. NOTE: This command is obsolete in newer versions of Docker Compose.
version: '3.8'
# Declares the project name for the Docker Compose application.
name: SOSMIT
# Defines the services that will be part of the Docker Compose application.
services:
# The name of the PostgreSQL database service. We can call it anything we like.
db:
# Tells Docker to use the official PostgreSQL image from Docker Hub.
# We're using version 16 of PostgreSQL, based on Alpine Linux (which is lightweight).
image: postgres:16-alpine
# This ensures that the database service is always restarted if it stops unexpectedly.
restart: always
# The initial configuration for the PostgreSQL database.
# IMPORTANT: In a real porduction, passwords should be managed with Docker secrets or other secure methods, NOT hardcoded at all.
environment:
POSTGRES_USER: sosmit_admin
POSTGRES_PASSWORD: admin123
POSTGRES_DB: sosmit_db
# This maps the PostgreSQL port 5432 on the host machine to the same port in the container.
# This allows us to connect to the database from outside the container, specifically the Go app (for this specific project).
ports:
- '5433:5432'
# To ensure data persistence, we mount a volume to the container.
# This means that the data stored in the database will be saved in a directory on the host machine.
# This tells Docker to create a named volume called 'db_data' and mount it to the PostgreSQL data directory (/var/lib/postgresql/data).
volumes:
- db_data:/var/lib/postgresql/data
backend:
build:
context: .
dockerfile: Dockerfile
target: production
env_file:
- .env
environment:
DB_HOST: db
DB_PORT: 5432
DB_USER: sosmit_admin
DB_PASSWORD: admin123
DB_NAME: sosmit_db
FRONTEND_URL: ${FRONTEND_URL}
BACKEND_URL: ${BACKEND_URL}
SENDGRID_API_KEY: ${SENDGRID_API_KEY}
SENDER_EMAIL: ${SENDER_EMAIL}
depends_on:
- db
ports:
- "8080:8080"
volumes:
- ./uploads:/app/uploads
# This top-level key defines the volumes that will be used by the services.
# It allows Docker to manage persistent data storage.
# The data in this volume will persist on your hard drive even if the container is removed or downed.
volumes:
db_data: