Skip to content

Commit

Permalink
Update Dockerfile and Docker workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
fvergaracl committed Feb 8, 2024
1 parent d1d8769 commit 3e9435e
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Docker Image
name: Publish Docker ALPHA Image

on:
workflow_dispatch:
Expand Down Expand Up @@ -37,3 +37,4 @@ jobs:
fvergaracl/game:latest
fvergaracl/game:${{ github.ref_name }}
fvergaracl/game:${{ github.ref_name }}-${{ github.run_number }}
target: prod
39 changes: 39 additions & 0 deletions .github/workflows/docker_alpha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish Docker ALPHA Image

on:
workflow_dispatch:
push:
tags:
- "*"
branches:
- main
pull_request:
branches:
- main

jobs:
docker:
runs-on: ubuntu-latest
if: github.ref_name != 'main'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker Image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
push: true
tags: |
fvergaracl/game:alpha-${{ github.ref_name }}
fvergaracl/game:alpha-${{ github.ref_name }}-${{ github.run_number }}
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ FROM builder as prod
RUN poetry install --no-root --no-dev --no-cache
RUN pip install gunicorn


CMD ["bash", "./app/start-prod.sh"]
CMD ["bash", "./app/start-prod.sh"]
17 changes: 15 additions & 2 deletions app/start-prod.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#! /usr/bin/env bash
# https://raw.githubusercontent.com/tiangolo/uvicorn-gunicorn-docker/master/docker-images/gunicorn_conf.py
#!/bin/bash

# Wait for PostgreSQL to become available
echo "Waiting for PostgreSQL to become available..."
while ! pg_isready -h $DB_HOST -p $DB_PORT -U $DB_USER; do
sleep 1
done

echo "PostgreSQL is up - executing Alembic migrations"
# Navigate to your project directory (where pyproject.toml is located)
cd /app/app
# Use poetry to run Alembic migrations
poetry run alembic upgrade head

cd /app

HOST=${HOST:-0.0.0.0}
PORT=${PORT}
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/deployments/gamificationengine-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ spec:
configMapKeyRef:
key: VERSION_APP
name: env-prod
image: fvergaracl/game:v0.0.002
image: fvergaracl/game:v0.0.003
name: game-api
restartPolicy: Always

0 comments on commit 3e9435e

Please sign in to comment.