From 82263ba4f97adb57665920b698160b2a83338373 Mon Sep 17 00:00:00 2001 From: Markus Skyttner Date: Tue, 17 Jan 2023 19:45:26 +0100 Subject: [PATCH 1/3] fix typo in log warning --- csvbase/web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csvbase/web.py b/csvbase/web.py index ff56469..2e898f0 100644 --- a/csvbase/web.py +++ b/csvbase/web.py @@ -106,7 +106,7 @@ def init_app() -> Flask: if "CSVBASE_SECRET_KEY" in environ: app.config["SECRET_KEY"] = environ["CSVBASE_SECRET_KEY"] else: - app.logger.warning("CSVBASE_SECERT_KEY not set, using a random secret") + app.logger.warning("CSVBASE_SECRET_KEY not set, using a random secret") app.config["SECRET_KEY"] = secrets.token_hex() Babel(app, default_locale="en_GB", default_timezone="Europe/London") From 176a696b1d4d452d98e2e9af31629eb53bdb5356 Mon Sep 17 00:00:00 2001 From: Markus Skyttner Date: Tue, 17 Jan 2023 20:06:50 +0100 Subject: [PATCH 2/3] minor changes to Dockerfile --- Dockerfile | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 875e30e..a1a02c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,30 @@ +# syntax=docker/dockerfile:1.4 FROM python:3.7-slim-buster as builder -RUN apt-get update -RUN apt-get install -y libpq-dev python3-dev libsystemd-dev build-essential pkg-config +RUN apt-get update && apt-get install -y \ + libpq-dev python3-dev libsystemd-dev build-essential pkg-config COPY ./ ./ RUN python -m pip wheel -w wheelhouse . FROM python:3.7-slim-buster -RUN apt-get update -RUN apt-get -y install libpq5 + +ENV PYTHONUNBUFFERED=1 +ENV TZ=UTC +ENV DEBIAN_FRONTEND=noninteractive +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +ENV TINI_VERSION="v0.19.0" +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN chmod +x /tini + +RUN apt-get update && apt-get -y install libpq5 COPY --from=builder wheelhouse wheelhouse RUN python -m pip --no-cache-dir install csvbase --no-index -f wheelhouse + ENV FLASK_APP=csvbase.web:init_app() ENV FLASK_ENV=production + EXPOSE 6001 + +ENTRYPOINT ["/tini", "--"] CMD ["gunicorn", "csvbase.web:init_app()", "-b", ":6001"] + From 262b029918be7e6947e007fe32e8f9dd7329c0fb Mon Sep 17 00:00:00 2001 From: Markus Skyttner Date: Tue, 17 Jan 2023 20:07:39 +0100 Subject: [PATCH 3/3] gha to publish container image w/ csvbase to ghcr.io --- .github/workflows/push.yaml | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/push.yaml diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml new file mode 100644 index 0000000..2b431b1 --- /dev/null +++ b/.github/workflows/push.yaml @@ -0,0 +1,54 @@ +on: + workflow_dispatch: + push: + branches: + - main +# paths: +# - 'Dockerfile' +# - '.github/workflows/push.yml' + +name: Push docker image to ghcr.io + +jobs: + push: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ghcr.io/${{ github.repository }} + tags: | + type=raw,value=1.0.${{ github.run_number }},priority=1000 + type=ref,event=branch + type=sha + type=raw,value=latest + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Docker build and push + uses: docker/build-push-action@v3 + with: + context: . + file: Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + push: true + cache-from: type=gha + cache-to: type=gha,mode=max