Finish docker setup

This commit is contained in:
Pavle Portic 2022-10-30 02:13:51 +02:00
parent 88f3a9b16f
commit 1593775e0f
Signed by: TheEdgeOfRage
GPG Key ID: 66AD4BA646FBC0D2
4 changed files with 26 additions and 4 deletions

View File

@ -5,9 +5,11 @@
!cmd !cmd
!config !config
!db !db
!feedparser
!handler !handler
!httpserver !httpserver
!lib !lib
!migrations
!mocks !mocks
!models !models

View File

@ -10,7 +10,7 @@ RUN make setup
COPY . /app/ COPY . /app/
RUN make build RUN make build
FROM debian:bullseye-slim FROM debian:bullseye-slim AS api
RUN apt update \ RUN apt update \
&& apt install -y ca-certificates \ && apt install -y ca-certificates \
&& apt clean \ && apt clean \
@ -18,3 +18,6 @@ RUN apt update \
COPY --from=builder /app/dist/ /app/ COPY --from=builder /app/dist/ /app/
ENTRYPOINT ["/app/ytrssil-api"] ENTRYPOINT ["/app/ytrssil-api"]
FROM migrate/migrate AS migrations
COPY ./migrations/ /migrations/

View File

@ -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 DB_URI ?= postgres://ytrssil:ytrssil@localhost:5431/ytrssil?sslmode=disable
@ -37,4 +37,10 @@ migrate:
image-build: image-build:
@echo "# Building docker image..." @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

View File

@ -17,7 +17,7 @@ services:
retries: 5 retries: 5
api: api:
build: . image: theedgeofrage/ytrssil:api
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
- postgres - postgres
@ -32,5 +32,16 @@ services:
retries: 5 retries: 5
timeout: 2s 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: volumes:
postgres-data: postgres-data: