Skip to content

Commit a1d9253

Browse files
l4rm4ndbenbusby
andauthored
chore: restructure compose example (#4)
* chore: restructure compose example * chore: add POSTGRES_HOST_AUTH_METHOD * Fix docker compose setup in tests --------- Co-authored-by: Ben Busby <[email protected]>
1 parent ca391b2 commit a1d9253

File tree

4 files changed

+35
-34
lines changed

4 files changed

+35
-34
lines changed

.github/workflows/go-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
docker volume create --name=yeetfile_data
2929
docker compose rm -f
3030
docker compose pull
31-
docker compose up --build -d
31+
docker compose --env-file .tests.env up --build -d
3232
docker compose logs
3333
3434
- name: Test API

.github/workflows/web-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
docker volume create --name=yeetfile_data
3636
docker compose rm -f
3737
docker compose pull
38-
docker compose up --build -d
38+
docker compose --env-file .tests.env up --build -d
3939
docker compose logs
4040
4141
pytest -vx -s --tracing=retain-on-failure ./web/tests/test_single_user.py

.tests.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ YEETFILE_PORT="8090"
88
YEETFILE_DB_USER="postgres"
99
YEETFILE_DB_PASS="postgres"
1010
YEETFILE_DB_NAME="yeetfile"
11-
YEETFILE_DB_HOST="localhost"
11+
YEETFILE_DB_HOST="db"

docker-compose.yml

+32-31
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
services:
2-
db:
3-
image: postgres
4-
restart: always
5-
container_name: database
6-
hostname: postgres
7-
volumes:
8-
- yeetfile_data:/var/lib/postgresql/data
9-
- ./backend/db/scripts/init.sql:/docker-entrypoint-initdb.d/init.sql
10-
environment:
11-
POSTGRES_HOST_AUTH_METHOD: md5
12-
POSTGRES_USER: ${YEETFILE_DB_USER:-postgres}
13-
POSTGRES_PASSWORD: ${YEETFILE_DB_PASS:-postgres}
14-
POSTGRES_DB: ${YEETFILE_DB_NAME:-yeetfile}
15-
#ports:
16-
# - "5432:5432" # Map db port to host
17-
healthcheck:
18-
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
19-
interval: 3s
202

213
api:
4+
image: ghcr.io/benbusby/yeetfile:0.0.2
225
container_name: yeetfile
23-
restart: always
24-
build:
25-
context: .
26-
dockerfile: Dockerfile
6+
restart: unless-stopped
277
ports:
28-
- "${YEETFILE_PORT:-8090}:${YEETFILE_PORT:-8090}"
8+
- 8090:${YEETFILE_PORT:-8090}
9+
expose:
10+
- 8090
2911
depends_on:
3012
db:
3113
condition: service_healthy
32-
env_file: "${YEETFILE_ENV_FILE:-template.env}"
3314
environment:
34-
YEETFILE_DB_HOST: "db"
35-
36-
# Map upload dir to host machine (local only)
15+
- YEETFILE_DEBUG=${YEETFILE_DEBUG:-0}
16+
- YEETFILE_STORAGE=${YEETFILE_STORAGE:-local}
17+
- YEETFILE_DEFAULT_USER_STORAGE=${YEETFILE_DEFAULT_USER_STORAGE:--1}
18+
- YEETFILE_DEFAULT_USER_SEND=${YEETFILE_DEFAULT_USER_SEND:--1}
19+
- YEETFILE_HOST=${YEETFILE_HOST:-0.0.0.0}
20+
- YEETFILE_PORT=${YEETFILE_PORT:-8090}
21+
- YEETFILE_DB_USER=${YEETFILE_DB_USER:-postgres}
22+
- YEETFILE_DB_PASS=${YEETFILE_DB_PASS:-postgres}
23+
- YEETFILE_DB_NAME=${YEETFILE_DB_NAME:-yeetfile}
24+
- YEETFILE_DB_HOST=${YEETFILE_DB_HOST:-db}
3725
volumes:
38-
- ~/.local/share/yeetfile/uploads:/app/uploads
26+
- ./volumes/yeetfile/uploads:/app/uploads
3927

40-
volumes:
41-
yeetfile_data:
42-
external: true # Run "docker volume create --name=yeetfile_data" beforehand
28+
db:
29+
image: postgres:16-alpine
30+
container_name: yeetfile-db
31+
restart: unless-stopped
32+
volumes:
33+
- ./volumes/yeetfile/data:/var/lib/postgresql/data
34+
environment:
35+
- POSTGRES_HOST_AUTH_METHOD=${POSTGRES_HOST_AUTH_METHOD:-md5}
36+
- POSTGRES_USER=${YEETFILE_DB_USER:-postgres}
37+
- POSTGRES_PASSWORD=${YEETFILE_DB_PASS:-postgres}
38+
- POSTGRES_DB=${YEETFILE_DB_NAME:-yeetfile}
39+
expose:
40+
- 5432
41+
healthcheck:
42+
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
43+
interval: 3s

0 commit comments

Comments
 (0)