Skip to content

Commit

Permalink
Setting bitnami gunicorn 3.9 as default image and pushing separate
Browse files Browse the repository at this point in the history
bitnami uvicorn image.

Signed-off-by: Maik Fischer <maik.fischer@lgln.niedersachsen.de>
  • Loading branch information
FischerLGLN committed Oct 6, 2022
1 parent 29439cc commit 92da41e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check_charts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
# See https://github.com/developmentseed/titiler/discussions/387
platforms: linux/amd64
context: .
file: dockerfiles/Dockerfile.gunicorn
file: dockerfiles/Dockerfile.uvicorn
push: false
tags: "titiler:dev"

Expand All @@ -75,4 +75,4 @@ jobs:
if: steps.list-changed.outputs.changed == 'true'

- name: Run chart-testing (install)
run: ct install --chart-dirs deployment/k8s
run: ct install --chart-dirs deployment/k8s
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,34 @@ jobs:
id: tag
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
# Uvicorn
# Push `latest` when commiting to master
- name: Build and push uvicorn
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v2
with:
# See https://github.com/developmentseed/titiler/discussions/387
platforms: linux/amd64
context: .
file: dockerfiles/Dockerfile.uvicorn
push: true
tags: |
ghcr.io/${{ github.repository }}-uvicorn:latest
# Push `{VERSION}` when pushing a new tag
- name: Build and push uvicorn
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
uses: docker/build-push-action@v2
with:
# See https://github.com/developmentseed/titiler/discussions/387
platforms: linux/amd64
context: .
file: dockerfiles/Dockerfile.uvicorn
push: true
tags: |
ghcr.io/${{ github.repository }}-uvicorn:${{ steps.tag.outputs.tag }}
# Gunicorn
# Push `latest` when commiting to master
- name: Build and push
if: github.ref == 'refs/heads/master'
Expand Down
2 changes: 1 addition & 1 deletion deployment/k8s/charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
replicaCount: 1

image:
repository: ghcr.io/developmentseed/titiler
repository: ghcr.io/developmentseed/titiler-uvicorn
tag: latest
pullPolicy: IfNotPresent

Expand Down
15 changes: 9 additions & 6 deletions dockerfiles/Dockerfile.gunicorn
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Dockerfile for running titiler application with gunicorn server
# Size ~1.4GB
# Dockerfile for running titiler application with uvicorn server
ARG PYTHON_VERSION=3.9

FROM tiangolo/uvicorn-gunicorn:python${PYTHON_VERSION}
FROM bitnami/python:${PYTHON_VERSION}
RUN apt update && apt upgrade -y \
&& apt install curl -y \
&& rm -rf /var/lib/apt/lists/*

# Ensure root certificates are always updated at evey container build
# and curl is using the latest version of them
Expand All @@ -13,8 +15,9 @@ RUN update-ca-certificates
ENV CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt

COPY src/titiler/ /tmp/titiler/
RUN pip install /tmp/titiler/core /tmp/titiler/mosaic /tmp/titiler/application --no-cache-dir --upgrade
RUN pip install uvicorn gunicorn /tmp/titiler/core /tmp/titiler/mosaic /tmp/titiler/application --no-cache-dir --upgrade
RUN rm -rf /tmp/titiler

ENV MODULE_NAME titiler.application.main
ENV VARIABLE_NAME app
ENV HOST 0.0.0.0
ENV PORT 80
CMD uvicorn titiler.application.main:app --host ${HOST} --port ${PORT}
10 changes: 5 additions & 5 deletions dockerfiles/Dockerfile.uvicorn
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Dockerfile for running titiler application with uvicorn server
# Size ~600MB
ARG PYTHON_VERSION=3.9

FROM python:${PYTHON_VERSION}-slim

RUN apt-get update && apt-get install curl -y
FROM bitnami/python:${PYTHON_VERSION}
RUN apt update && apt upgrade -y \
&& apt install curl -y \
&& rm -rf /var/lib/apt/lists/*

# Ensure root certificates are always updated at evey container build
# and curl is using the latest version of them
Expand All @@ -15,7 +15,7 @@ RUN update-ca-certificates
ENV CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt

COPY src/titiler/ /tmp/titiler/
RUN pip install /tmp/titiler/core /tmp/titiler/mosaic /tmp/titiler/application["server"] --no-cache-dir --upgrade
RUN pip install uvicorn /tmp/titiler/core /tmp/titiler/mosaic /tmp/titiler/application["server"] --no-cache-dir --upgrade
RUN rm -rf /tmp/titiler

ENV HOST 0.0.0.0
Expand Down

0 comments on commit 92da41e

Please sign in to comment.