Skip to content

Commit

Permalink
Merge pull request #6 from UNDP-Data/feat/cicd
Browse files Browse the repository at this point in the history
Feat/cicd
  • Loading branch information
iferencik authored Nov 10, 2023
2 parents 68aaff7 + 1adc128 commit 2b0d946
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 1 deletion.
45 changes: 45 additions & 0 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build, publish and deploy

on:
push:
branches: ['main']
pull_request:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
# - name: Checkout repository
# uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:

context: .
file: Dockerfile
push: ${{ github.ref == 'refs/heads/main'}}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
secret-files: |
"GDAL_RIO=../gdal_rio.env"
16 changes: 15 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
FROM ghcr.io/developmentseed/titiler-uvicorn:latest
FROM ghcr.io/osgeo/gdal:ubuntu-small-latest as base

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libffi-dev python3-pip
RUN python3 -m pip install pipenv
RUN export PYTHON_VERSION="$(python3 --version | cut -d ' ' -f 2)" && pipenv --python ${PYTHON_VERSION}
RUN pipenv run pip install -U pip
RUN pipenv run pip install uvicorn titiler asyncpg postgis --no-cache-dir --upgrade


WORKDIR /opt/server
COPY src/cogserver cogserver

CMD pipenv run uvicorn cogserver:app --host ${HOST} --port ${PORT}
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3'

services:
cogserver:
# See https://github.com/developmentseed/titiler/discussions/387
#platform: linux/amd64
# enable `image` if you would like to use Docker image from Github package
# image: ghcr.io/undp-data/titiler-aks:v0.0.2
# enable `build` if you would like to build Docker image from source code
build:
context: .

# Enable the following volumes if you want to mount source code to Docker
# volumes:
# - "./app/wmts.py:/opt/wmts/wmts.py"
env_file:
- gdal_rio.env
ports:
- 8000:80
# environment:
# # Application
# - HOST=0.0.0.0
# - PORT=8000


19 changes: 19 additions & 0 deletions gdal_rio.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#Application
HOST=0.0.0.0
PORT=80
## Uvicorn
## http://www.uvicorn.org/settings/#production
WEB_CONCURRENCY=2
## GDAL config
CPL_TMPDIR=/tmp
GDAL_CACHEMAX=75%
GDAL_INGESTED_BYTES_AT_OPEN=32768
GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR
GDAL_HTTP_MERGE_CONSECUTIVE_RANGES=YES
GDAL_HTTP_MULTIPLEX=YES
GDAL_HTTP_VERSION=2
PYTHONWARNINGS=ignore
VSI_CACHE=TRUE
VSI_CACHE_SIZE=5000000
## rio-tiler config
RIO_TILER_MAX_THREADS=2

0 comments on commit 2b0d946

Please sign in to comment.