Skip to content

Commit a3166d8

Browse files
feat: deploy images to docker hub via gh action (#413)
* feat: add action for pushing docker images to docker hub on push * only manually triggered as of now
1 parent 2c345e8 commit a3166d8

File tree

3 files changed

+51
-12
lines changed

3 files changed

+51
-12
lines changed

.env.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SERVER_PORT=4001
2-
PGSQL_URL=postgresql://postgres:password@localhost:5432/postgres
2+
PGSQL_URL=postgresql://postgres:postgres@db:5432/postgres
33
POSTGRES_DATABASE=postgres
44
POSTGRES_PASSWORD=postgres
55
REDIS_PASSWORD=password
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Deploy latest docker image build to hub
2+
3+
on:
4+
# push:
5+
# branches:
6+
# - main
7+
8+
workflow_dispatch:
9+
inputs:
10+
image:
11+
description: 'Enter the latest image tag'
12+
required: true
13+
14+
jobs:
15+
deploy-docker-to-hub:
16+
runs-on: ubuntu-latest
17+
if: |
18+
${{ github.ref == 'refs/heads/main' }} &&
19+
${{ github.event_name == 'workflow_dispatch' }}
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v2
24+
with:
25+
ref: refs/heads/main
26+
27+
- name: Docker Login
28+
uses: docker/login-action@v3
29+
with:
30+
username: ${{ secrets.DOCKER_USERNAME }}
31+
password: ${{ secrets.DOCKER_TOKEN }}
32+
33+
- name: Build docker images
34+
run: docker-compose build
35+
36+
- name: Push docker images to docker hub
37+
run: docker-compose push

docker-compose.yml

+13-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
POSTGRES_DB: ${POSTGRES_DATABASE:-postgres}
1313
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
1414
healthcheck:
15-
test: ["CMD-SHELL", "pg_isready -U postgres"]
15+
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
1616
interval: 10s
1717
timeout: 5s
1818
retries: 5
@@ -22,43 +22,45 @@ services:
2222
ports:
2323
- '6379:6379'
2424
command: redis-server --save 20 1 --loglevel warning --requirepass ${REDIS_PASSWORD}
25-
volumes:
25+
volumes:
2626
- cache:/data
2727
db-seed:
28-
build:
28+
build:
2929
dockerfile: packages/backend/db-seed.Dockerfile
3030
context: "./"
3131
args:
3232
PGSQL_URL: postgresql://postgres:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DATABASE}
3333
depends_on:
3434
- db
35-
profiles: ["tools"]
35+
profiles: [ "tools" ]
3636
ui:
37-
build:
37+
build:
3838
dockerfile: packages/client/Dockerfile
3939
context: "./"
40+
image: revertengg/revert-ui-ce
4041
env_file:
4142
- packages/client/.env
42-
ports:
43+
ports:
4344
- 3000:3000
44-
api:
45-
build:
45+
api:
46+
build:
4647
dockerfile: packages/backend/Dockerfile
4748
context: "./"
4849
args:
4950
PGSQL_URL: postgresql://postgres:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DATABASE}
5051
SERVER_PORT: ${SERVER_PORT}
5152
REDIS_SERVER_URL: redis://${REDIS_USER}:${REDIS_PASSWORD}@cache:6379
53+
image: revertengg/revert-api-ce
5254
env_file:
5355
- packages/backend/.env
5456
ports:
5557
- 4001:4001
5658
depends_on:
5759
db:
58-
condition: service_healthy # Wait for db service to be healthy
59-
cache:
60+
condition: service_healthy # Wait for db service to be healthy
61+
cache:
6062
condition: service_started
6163

6264
volumes:
6365
pgdata:
64-
cache:
66+
cache:

0 commit comments

Comments
 (0)