Skip to content

Commit

Permalink
Feat/push docker to public repo (#17)
Browse files Browse the repository at this point in the history
* feat: change gha to push to public docker hub repo

* refactor: removed unused env vars

* added DB_URL to .env to be configurable for local setup, added docker image to compose.yml, testing docker github actions

* removed test branch from action

* added latest to build action
  • Loading branch information
Kammerlo authored May 27, 2024
1 parent c94e91e commit 47f6cf0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ DB_PASSWORD="metadata1337_"
DB_NAME="cf_token_metadata_registry"
DB_HOST='db'
DB_PORT='5432'
DB_URL=jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}

# API Details
API_EXPOSED_PORT='8080'
API_LOCAL_BIND_PORT='18080'

# Whether the github scheduled job should run on the api or not
TOKEN_METADATA_SYNC_JOB='true'
API_IMAGE_TAG=latest
5 changes: 0 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ on:
branches: [ main ]
workflow_dispatch:

env:
PRIVATE_MVN_REGISTRY_TOKEN: ${{ secrets.GITLAB_PKG_REGISTRY_TOKEN }}
PRIVATE_MVN_REGISTRY_URL: ${{ secrets.GITLAB_MAVEN_REGISTRY_URL }}
PRIVATE_DOCKER_REGISTRY_URL: ${{ secrets.GITLAB_DOCKER_REGISTRY_URL }}

jobs:
build:
runs-on: ubuntu-latest
Expand Down
21 changes: 10 additions & 11 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ on:
workflow_dispatch:

env:
PRIVATE_DOCKER_REGISTRY_URL: ${{ secrets.GITLAB_DOCKER_REGISTRY_URL }}
PRIVATE_DOCKER_REGISTRY_USER: Deploy-Token
PRIVATE_DOCKER_REGISTRY_PASS: ${{ secrets.GITLAB_PKG_REGISTRY_TOKEN }}
DOCKER_REPO: cardanofoundation
DOCKER_REGISTRY_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_REGISTRY_PASS: ${{ secrets.DOCKERHUB_TOKEN }}

jobs:

Expand Down Expand Up @@ -61,9 +61,8 @@ jobs:
- name: Private Docker Hub Login
uses: docker/login-action@v2
with:
registry: ${{ env.PRIVATE_DOCKER_REGISTRY_URL }}
username: ${{ env.PRIVATE_DOCKER_REGISTRY_USER }}
password: ${{ env.PRIVATE_DOCKER_REGISTRY_PASS }}
username: ${{ env.DOCKER_REGISTRY_USER }}
password: ${{ env.DOCKER_REGISTRY_PASS }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -76,7 +75,7 @@ jobs:
context: api
push: true
tags: |
${{ env.PRIVATE_DOCKER_REGISTRY_URL }}/${{ env.APP_NAME }}:${{ env.ARTIFACT_VERSION }}
${{ env.DOCKER_REPO }}/${{ env.APP_NAME }}:${{ env.ARTIFACT_VERSION }} , ${{ env.DOCKER_REPO }}/${{ env.APP_NAME }}:latest
job:
runs-on: ubuntu-latest
Expand All @@ -99,9 +98,8 @@ jobs:
- name: Private Docker Hub Login
uses: docker/login-action@v2
with:
registry: ${{ env.PRIVATE_DOCKER_REGISTRY_URL }}
username: ${{ env.PRIVATE_DOCKER_REGISTRY_USER }}
password: ${{ env.PRIVATE_DOCKER_REGISTRY_PASS }}
username: ${{ env.DOCKER_REGISTRY_USER }}
password: ${{ env.DOCKER_REGISTRY_PASS }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -114,4 +112,5 @@ jobs:
context: job
push: true
tags: |
${{ env.PRIVATE_DOCKER_REGISTRY_URL }}/${{ env.APP_NAME }}:${{ env.ARTIFACT_VERSION }}
${{ env.DOCKER_REPO }}/${{ env.APP_NAME }}:${{ env.ARTIFACT_VERSION }} , ${{ env.DOCKER_REPO }}/${{ env.APP_NAME }}:latest
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
db:
image: postgres:15
ports:
- "${DB_PORT}:${DB_PORT}"
- "${DB_PORT}:5432"
environment:
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
volumes:
Expand All @@ -15,13 +15,14 @@ services:
retries: 10
restart: on-failure
api:
image: cardanofoundation/cf-token-metadata-registry-api:${API_IMAGE_TAG}
build:
context: .
dockerfile: api/compose.dockerfile
ports:
- "${API_LOCAL_BIND_PORT}:${API_EXPOSED_PORT}"
environment:
DB_URL: "jdbc:postgresql://db:${DB_PORT}/${DB_NAME}"
DB_URL: "${DB_URL}"
DB_USERNAME: "${DB_USERNAME}"
DB_PASSWORD: "${DB_PASSWORD}"
TOKEN_METADATA_SYNC_JOB: "${TOKEN_METADATA_SYNC_JOB}"
Expand Down

0 comments on commit 47f6cf0

Please sign in to comment.