Skip to content

Commit 574aec5

Browse files
Add a prod image building workflow
1 parent 439280a commit 574aec5

2 files changed

Lines changed: 72 additions & 40 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Build Production Image
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v2
18+
19+
- name: Log in to Docker Hub
20+
uses: docker/login-action@v2
21+
with:
22+
username: ${{ secrets.DOCKERHUB_USERNAME }}
23+
password: ${{ secrets.DOCKERHUB_TOKEN }}
24+
25+
- name: Extract version from tag
26+
id: get_version
27+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
28+
29+
- name: Build and push
30+
uses: docker/build-push-action@v4
31+
with:
32+
context: .
33+
push: true
34+
build-args: |
35+
ENVIRONMENT=production
36+
tags: |
37+
peterrauscher/solesearch-api:latest
38+
peterrauscher/solesearch-api:${{ steps.get_version.outputs.VERSION }}
39+
cache-from: type=gha
40+
cache-to: type=gha,mode=max

docker-compose.prod.yml

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,8 @@
11
services:
2-
nginx:
3-
image: nginx:alpine
4-
container_name: solesearch_nginx
5-
ports:
6-
- "80:80"
7-
- "443:443"
8-
volumes:
9-
- ./nginx/templates:/etc/nginx/templates
10-
- ./nginx/certbot/etc/letsencrypt:/etc/letsencrypt
11-
- ./nginx/certbot/var/www/certbot:/var/www/certbot
12-
depends_on:
13-
- api
14-
networks:
15-
- solesearch_network
16-
restart: always
17-
18-
certbot:
19-
image: certbot/certbot:latest
20-
container_name: solesearch_certbot
21-
command: certonly --reinstall --webroot --webroot-path=/var/www/certbot --email ${EMAIL} --agree-tos --no-eff-email -d ${DOMAIN}
22-
volumes:
23-
- ./nginx/certbot/etc/letsencrypt:/etc/letsencrypt
24-
- ./nginx/certbot/var/www/certbot:/var/www/certbot
25-
depends_on:
26-
- nginx
27-
restart: unless-stopped
28-
env_file:
29-
- ".env"
302

313
api:
32-
build:
33-
context: .
34-
args:
35-
- ENVIRONMENT=production
364
container_name: solesearch_api
5+
image: peterrauscher/solesearch-api:latest
376
depends_on:
387
- db
398
- redis
@@ -46,11 +15,8 @@ services:
4615
- ".env"
4716

4817
celery_worker:
49-
build:
50-
context: .
51-
args:
52-
- ENVIRONMENT=production
5318
container_name: solesearch_worker
19+
image: peterrauscher/solesearch-api:latest
5420
command: celery -A solesearch_api.tasks worker --loglevel=info
5521
depends_on:
5622
- api
@@ -65,11 +31,8 @@ services:
6531
- ".env"
6632

6733
celery_beat:
68-
build:
69-
context: .
70-
args:
71-
- ENVIRONMENT=production
7234
container_name: solesearch_beat
35+
image: peterrauscher/solesearch-api:latest
7336
command: celery -A solesearch_api.tasks beat --loglevel=info
7437
depends_on:
7538
- api
@@ -116,6 +79,35 @@ services:
11679
env_file:
11780
- ".env"
11881

82+
nginx:
83+
image: nginx:alpine
84+
container_name: solesearch_nginx
85+
ports:
86+
- "80:80"
87+
- "443:443"
88+
volumes:
89+
- ./nginx/templates:/etc/nginx/templates
90+
- ./nginx/certbot/etc/letsencrypt:/etc/letsencrypt
91+
- ./nginx/certbot/var/www/certbot:/var/www/certbot
92+
depends_on:
93+
- api
94+
networks:
95+
- solesearch_network
96+
restart: always
97+
98+
certbot:
99+
image: certbot/certbot:latest
100+
container_name: solesearch_certbot
101+
command: certonly --reinstall --webroot --webroot-path=/var/www/certbot --email ${EMAIL} --agree-tos --no-eff-email -d ${DOMAIN}
102+
volumes:
103+
- ./nginx/certbot/etc/letsencrypt:/etc/letsencrypt
104+
- ./nginx/certbot/var/www/certbot:/var/www/certbot
105+
depends_on:
106+
- nginx
107+
restart: unless-stopped
108+
env_file:
109+
- ".env"
110+
119111
volumes:
120112
postgres_data:
121113
redis_data:

0 commit comments

Comments
 (0)