From 1593775e0f3e3f30b944624e5d6be5c26c091906 Mon Sep 17 00:00:00 2001 From: Pavle Portic Date: Sun, 30 Oct 2022 02:13:51 +0200 Subject: [PATCH] Finish docker setup --- .dockerignore | 2 ++ Dockerfile | 5 ++++- Makefile | 10 ++++++++-- docker-compose.yml | 13 ++++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index e6445b4..89e0ff2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,9 +5,11 @@ !cmd !config !db +!feedparser !handler !httpserver !lib +!migrations !mocks !models diff --git a/Dockerfile b/Dockerfile index 6ff0d9b..2ac7f55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN make setup COPY . /app/ RUN make build -FROM debian:bullseye-slim +FROM debian:bullseye-slim AS api RUN apt update \ && apt install -y ca-certificates \ && apt clean \ @@ -18,3 +18,6 @@ RUN apt update \ COPY --from=builder /app/dist/ /app/ ENTRYPOINT ["/app/ytrssil-api"] + +FROM migrate/migrate AS migrations +COPY ./migrations/ /migrations/ diff --git a/Makefile b/Makefile index 225859c..874daa5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all setup ytrssil-api build lint k8s-lint yamllint test test-initdb image-build +.PHONY: all setup ytrssil-api build gen-mocks lint yamllint test migrate image-build image-push DB_URI ?= postgres://ytrssil:ytrssil@localhost:5431/ytrssil?sslmode=disable @@ -37,4 +37,10 @@ migrate: image-build: @echo "# Building docker image..." - docker build -t ytrssil-api -f Dockerfile . + docker build -t theedgeofrage/ytrssil:api --target api . + docker build -t theedgeofrage/ytrssil:migrations --target migrations . + +image-push: image-build + @echo "# Pushing docker image..." + docker push theedgeofrage/ytrssil:api + docker push theedgeofrage/ytrssil:migrations diff --git a/docker-compose.yml b/docker-compose.yml index c399c30..e50e567 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ services: retries: 5 api: - build: . + image: theedgeofrage/ytrssil:api restart: unless-stopped depends_on: - postgres @@ -32,5 +32,16 @@ services: retries: 5 timeout: 2s + migrations: + image: theedgeofrage/ytrssil:migrations + restart: unless-stopped + depends_on: + - postgres + command: + - "-path=/migrations/" + - "-database" + - "postgresql://ytrssil:ytrssil@postgres/ytrssil?sslmode=disable" + - "up" + volumes: postgres-data: