From ab0c767f7a3a1cd303e44cf880e10b0ef9fdc989 Mon Sep 17 00:00:00 2001 From: Aaron Luna Date: Fri, 5 Jan 2024 19:36:12 -0800 Subject: [PATCH] Update Docker actions and environment variables --- .github/workflows/deploy_unicode_api.yml | 11 ++++--- Dockerfile | 40 ++++++++++++------------ docker-bake.hcl | 20 ++++++------ 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/.github/workflows/deploy_unicode_api.yml b/.github/workflows/deploy_unicode_api.yml index 01eb97b..0a905ab 100644 --- a/.github/workflows/deploy_unicode_api.yml +++ b/.github/workflows/deploy_unicode_api.yml @@ -1,4 +1,4 @@ -name: deploy unicode-api +name: deploy-unicode-api on: push: @@ -11,21 +11,22 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to Github Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GHCR_TOKEN }} - name: Bake unicode-api image and push to github container registry - uses: docker/bake-action@v3.1.0 + uses: docker/bake-action@v4.1.0 with: files: ./docker-bake.hcl targets: unicode-api push: true + set: unicode-api.args.REDIS_PW=${{ secrets.REDIS_PW }} - name: Deploy unicode-api docker image to dokku uses: dokku/github-action@master with: diff --git a/Dockerfile b/Dockerfile index 66a4cd8..5b292c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,26 @@ FROM python:3.11 -ARG ARG_ENV -ARG ARG_UNICODE_VERSION -ARG ARG_REDIS_HOST -ARG ARG_REDIS_PORT -ARG ARG_REDIS_DB -ARG ARG_REDIS_PW -ARG ARG_RATE_LIMIT_PER_PERIOD -ARG ARG_RATE_LIMIT_PERIOD_SECONDS -ARG ARG_RATE_LIMIT_BURST -ARG ARG_TEST_HEADER +ARG ENV +ARG UNICODE_VERSION +ARG REDIS_HOST +ARG REDIS_PORT +ARG REDIS_DB +ARG REDIS_PW +ARG RATE_LIMIT_PER_PERIOD +ARG RATE_LIMIT_PERIOD_SECONDS +ARG RATE_LIMIT_BURST +ARG TEST_HEADER -ENV ENV=${ARG_ENV} -ENV UNICODE_VERSION=${ARG_UNICODE_VERSION} -ENV REDIS_HOST=${ARG_REDIS_HOST} -ENV REDIS_PORT=${ARG_REDIS_PORT} -ENV REDIS_DB=${ARG_REDIS_DB} -ENV REDIS_PW=${ARG_REDIS_PW} -ENV RATE_LIMIT_PER_PERIOD=${ARG_RATE_LIMIT_PER_PERIOD} -ENV RATE_LIMIT_PERIOD_SECONDS=${ARG_RATE_LIMIT_PERIOD_SECONDS} -ENV RATE_LIMIT_BURST=${ARG_RATE_LIMIT_BURST} -ENV TEST_HEADER=${ARG_TEST_HEADER} +ENV ENV=${ENV} +ENV UNICODE_VERSION=${UNICODE_VERSION} +ENV REDIS_HOST=${REDIS_HOST} +ENV REDIS_PORT=${REDIS_PORT} +ENV REDIS_DB=${REDIS_DB} +ENV REDIS_PW=${REDIS_PW} +ENV RATE_LIMIT_PER_PERIOD=${RATE_LIMIT_PER_PERIOD} +ENV RATE_LIMIT_PERIOD_SECONDS=${RATE_LIMIT_PERIOD_SECONDS} +ENV RATE_LIMIT_BURST=${RATE_LIMIT_BURST} +ENV TEST_HEADER=${TEST_HEADER} WORKDIR /code RUN pip install -U pip setuptools wheel diff --git a/docker-bake.hcl b/docker-bake.hcl index 5ec4be5..22cd7f9 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -10,15 +10,15 @@ target "unicode-api" { dockerfile = "./Dockerfile" tags = ["ghcr.io/a-luna/unicode-api:${GITHUB_SHA}"] args = { - ARG_ENV = "PROD" - ARG_UNICODE_VERSION = "15.1.0" - ARG_REDIS_HOST = "dokku-redis-vig-cache" - ARG_REDIS_PORT = "6379" - ARG_REDIS_DB = "1" - ARG_REDIS_PW = "${REDIS_PW}" - ARG_RATE_LIMIT_PER_PERIOD = "50" - ARG_RATE_LIMIT_PERIOD_SECONDS = "60" - ARG_RATE_LIMIT_BURST = "10" - ARG_TEST_HEADER = "X-UnicodeAPI-Test" + ENV = "PROD" + UNICODE_VERSION = "15.1.0" + REDIS_HOST = "dokku-redis-vig-cache" + REDIS_PORT = "6379" + REDIS_DB = "1" + REDIS_PW = "${REDIS_PW}" + RATE_LIMIT_PER_PERIOD = "50" + RATE_LIMIT_PERIOD_SECONDS = "60" + RATE_LIMIT_BURST = "10" + TEST_HEADER = "X-UnicodeAPI-Test" } }