1593775e0f3e3f30b944624e5d6be5c26c091906

Author
Pavle Portic <git@theedgeofrage.com>
Committer
Pavle Portic <git@theedgeofrage.com>
Date

Message

Finish docker setup

Diff

 1diff --git a/.dockerignore b/.dockerignore
 2index e6445b4dd0042b1297a4483ccff9d3c1cfa6dfcd..89e0ff25e582146c466e0971ea988ca673c46052 100644
 3--- a/.dockerignore
 4+++ b/.dockerignore
 5@@ -5,9 +5,11 @@
 6 !cmd
 7 !config
 8 !db
 9+!feedparser
10 !handler
11 !httpserver
12 !lib
13+!migrations
14 !mocks
15 !models
16 
17diff --git a/Dockerfile b/Dockerfile
18index 6ff0d9bbe009fec8d61895846128a260c7d2737d..2ac7f55e1bdd36c58a3e5ee98ce1b819454c6ba6 100644
19--- a/Dockerfile
20+++ b/Dockerfile
21@@ -10,7 +10,7 @@ RUN make setup
22 COPY . /app/
23 RUN make build
24 
25-FROM debian:bullseye-slim
26+FROM debian:bullseye-slim AS api
27 RUN apt update \
28 	&& apt install -y ca-certificates \
29 	&& apt clean \
30@@ -18,3 +18,6 @@ RUN apt update \
31 
32 COPY --from=builder /app/dist/ /app/
33 ENTRYPOINT ["/app/ytrssil-api"]
34+
35+FROM migrate/migrate AS migrations
36+COPY ./migrations/ /migrations/
37diff --git a/Makefile b/Makefile
38index 225859c98a1af1d649ef175bc9b80178fe6ae1dc..874daa5cf374fa594074ad795cfe1503595a1a9d 100644
39--- a/Makefile
40+++ b/Makefile
41@@ -1,4 +1,4 @@
42-.PHONY: all setup ytrssil-api build lint k8s-lint yamllint test test-initdb image-build
43+.PHONY: all setup ytrssil-api build gen-mocks lint yamllint test migrate image-build image-push
44 
45 DB_URI ?= postgres://ytrssil:ytrssil@localhost:5431/ytrssil?sslmode=disable
46 
47@@ -37,4 +37,10 @@ migrate:
48 
49 image-build:
50 	@echo "# Building docker image..."
51-	docker build -t ytrssil-api -f Dockerfile .
52+	docker build -t theedgeofrage/ytrssil:api --target api .
53+	docker build -t theedgeofrage/ytrssil:migrations --target migrations .
54+
55+image-push: image-build
56+	@echo "# Pushing docker image..."
57+	docker push theedgeofrage/ytrssil:api
58+	docker push theedgeofrage/ytrssil:migrations
59diff --git a/docker-compose.yml b/docker-compose.yml
60index c399c30a904f14c88d77f7ba9ffb8a755d6c98f6..e50e567da9d6de9f7ae5be37a60c5b49db528046 100644
61--- a/docker-compose.yml
62+++ b/docker-compose.yml
63@@ -17,7 +17,7 @@ services:
64       retries: 5
65 
66   api:
67-    build: .
68+    image: theedgeofrage/ytrssil:api
69     restart: unless-stopped
70     depends_on:
71       - postgres
72@@ -32,5 +32,16 @@ services:
73       retries: 5
74       timeout: 2s
75 
76+  migrations:
77+    image: theedgeofrage/ytrssil:migrations
78+    restart: unless-stopped
79+    depends_on:
80+      - postgres
81+    command:
82+      - "-path=/migrations/"
83+      - "-database"
84+      - "postgresql://ytrssil:ytrssil@postgres/ytrssil?sslmode=disable"
85+      - "up"
86+
87 volumes:
88   postgres-data: