forked from ikseer/Back-End
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdocker-compose.yml
62 lines (53 loc) · 1.65 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
version: "3.8"
services:
project:
build: .
command: gunicorn --bind 0.0.0.0:8000 project.wsgi
volumes:
- ./project:/usr/src/project
expose:
- 8000
nginx:
image: nginx:1.25-alpine
ports:
- "80:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./project/static:/usr/src/project/static
depends_on:
- project
name: Build and Publish Images
on:
push:
branches: [main]
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push Django app image
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile.django # Use separate Dockerfiles for each image
push: true
tags: your-username/django-app:latest # Customize image names
build-args: DJANGO_SETTINGS_MODULE=${{ secrets.DJANGO_SETTINGS_MODULE }} # Inject secret environment variable
- name: Build and push Nginx image
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile.nginx
push: true
tags: your-username/nginx:latest # Customize image names
- name: (Optional) Build tagged images for each commit (skip for production)
if: always()
run: |
# Build and push separate tags for Django and Nginx with commit SHA
# Consider separate jobs or workflow for production