Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 19 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +15 to +17

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me this is now built-in to docker but happy to include it as that makes it the default


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"]

2 changes: 1 addition & 1 deletion csvbase/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down