Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Migrate.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM postgres:15.3-alpine
WORKDIR /var
RUN apk update && \
apk add jq wget
RUN mkdir /var/migrations && \
# Create a list of download URLs for migration files
wget -q -O - https://api.github.com/repos/open-sauced/api/contents/migrations \
| jq --raw-output '.[].download_url' \
> ./original_urls.txt
# Downloads all SQL files into /var/migrations
RUN wget -q -P /var/migrations -i ./original_urls.txt && \
cat /var/migrations/*.sql > /var/all-migrations.sql
# Rename password from environment and run file
CMD PGPASSWORD=${POSTGRES_PASSWORD} psql \
--host db \
--username postgres \
--dbname postgres \
-f /var/all-migrations.sql
44 changes: 44 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
services:
db:
image: postgres:15.3-alpine
ports:
- "5432:5432"
environment:
- POSTGRES_PASSWORD=pw
healthcheck:
test: ["CMD-SHELL", "pg_isready", "-U", "postgres"]
interval: 30s
timeout: 10s
retries: 3
migrate:
build:
dockerfile: Migrate.Dockerfile
context: .
environment:
- POSTGRES_PASSWORD=pw
depends_on:
db:
condition: service_healthy
app:
image: golang:1.20-alpine
ports:
- "8080:8080"
depends_on:
db:
condition: service_healthy
migrate:
condition: service_completed_successfully
volumes:
- .:/app
working_dir: /app
command: go run main.go -sslmode-disable -debug
environment:
- DATABASE_PORT=5432
- DATABASE_HOST=db
- DATABASE_USER=postgres
- DATABASE_PASSWORD=pw
- DATABASE_DBNAME=postgres
- SERVER_PORT=8080
- GIT_PROVIDER=cache
- CACHE_DIR=/tmp
- MIN_FREE_DISK_GB=25