Skip to content

Commit 2bbec95

Browse files
committed
add uvicorn docker for kubernetes
1 parent 2b56b79 commit 2bbec95

File tree

5 files changed

+282
-0
lines changed

5 files changed

+282
-0
lines changed

.github/workflows/ci.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,106 @@ jobs:
6969

7070
- name: Stop services
7171
run: docker-compose stop
72+
73+
74+
publish-docker:
75+
needs: [tests]
76+
if: github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v3
81+
82+
- name: Set up QEMU
83+
uses: docker/setup-qemu-action@v1
84+
85+
- name: Set up Docker Buildx
86+
uses: docker/setup-buildx-action@v1
87+
88+
- name: Login to DockerHub
89+
uses: docker/login-action@v1
90+
with:
91+
username: ${{ secrets.DOCKERHUB_USERNAME }}
92+
password: ${{ secrets.DOCKERHUB_TOKEN }}
93+
94+
- name: Login to Github
95+
uses: docker/login-action@v1
96+
with:
97+
registry: ghcr.io
98+
username: ${{ github.actor }}
99+
password: ${{ secrets.GITHUB_TOKEN }}
100+
101+
- name: Set tag version
102+
id: tag
103+
run: |
104+
echo "version=${GITHUB_REF#refs/*/}"
105+
echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
106+
107+
#############################################################################
108+
# RASTER
109+
- name: RASTER - Build and push latest
110+
if: github.ref == 'refs/heads/main'
111+
uses: docker/build-push-action@v2
112+
with:
113+
platforms: linux/amd64
114+
context: .
115+
file: dockerfiles/Dockerfile.raster-uvicorn
116+
push: true
117+
tags: |
118+
ghcr.io/${{ github.repository }}-raster:latest
119+
120+
- name: RASTER - Build and push tags
121+
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
122+
uses: docker/build-push-action@v2
123+
with:
124+
platforms: linux/amd64
125+
context: .
126+
file: dockerfiles/Dockerfile.raster-uvicorn
127+
push: true
128+
tags: |
129+
ghcr.io/${{ github.repository }}-raster:${{ steps.tag.outputs.tag }}
130+
131+
#############################################################################
132+
# STAC
133+
- name: STAC - Build and push latest
134+
if: github.ref == 'refs/heads/main'
135+
uses: docker/build-push-action@v2
136+
with:
137+
context: .
138+
file: dockerfiles/Dockerfile.stac-uvicorn
139+
push: true
140+
tags: |
141+
ghcr.io/${{ github.repository }}-stac:latest
142+
143+
- name: STAC - Build and push tags
144+
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
145+
uses: docker/build-push-action@v2
146+
with:
147+
context: .
148+
file: dockerfiles/Dockerfile.stac-uvicorn
149+
push: true
150+
tags: |
151+
ghcr.io/${{ github.repository }}-stac:${{ steps.tag.outputs.tag }}
152+
153+
#############################################################################
154+
# VECTOR
155+
- name: VECTOR - Build and push latest
156+
if: github.ref == 'refs/heads/main'
157+
uses: docker/build-push-action@v2
158+
with:
159+
context: .
160+
file: dockerfiles/Dockerfile.vector-uvicorn
161+
push: true
162+
tags: |
163+
ghcr.io/${{ github.repository }}-vector:latest
164+
165+
- name: VECTOR - Build and push tags
166+
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
167+
uses: docker/build-push-action@v2
168+
with:
169+
context: .
170+
file: dockerfiles/Dockerfile.vector-uvicorn
171+
push: true
172+
tags: |
173+
ghcr.io/${{ github.repository }}-vector:${{ steps.tag.outputs.tag }}
174+

docker-compose.uvicorn.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
version: '3'
2+
3+
services:
4+
stac-uvicorn:
5+
container_name: eoapi.stac-uvicorn
6+
build:
7+
context: .
8+
dockerfile: dockerfiles/Dockerfile.stac-uvicorn
9+
ports:
10+
- "${MY_DOCKER_IP:-127.0.0.1}:8081:8081"
11+
environment:
12+
- APP_HOST=0.0.0.0
13+
- APP_PORT=8081
14+
- HOST=0.0.0.0
15+
- PORT=8081
16+
- ENVIRONMENT=local
17+
# Postgres connection
18+
- POSTGRES_USER=username
19+
- POSTGRES_PASS=password
20+
- POSTGRES_DBNAME=postgis
21+
- POSTGRES_HOST_READER=database
22+
- POSTGRES_HOST_WRITER=database
23+
- POSTGRES_PORT=5432
24+
- DB_MIN_CONN_SIZE=1
25+
- DB_MAX_CONN_SIZE=10
26+
# https://github.com/developmentseed/eoAPI/issues/16
27+
# - TITILER_ENDPOINT=raster
28+
- TITILER_ENDPOINT=http://127.0.0.1:8082
29+
depends_on:
30+
- database
31+
- raster-uvicorn
32+
command:
33+
bash -c "bash /tmp/scripts/wait-for-it.sh -t 120 -h database -p 5432 && uvicorn eoapi.stac.app:app --host 0.0.0.0 --port 8081"
34+
volumes:
35+
- ./dockerfiles/scripts:/tmp/scripts
36+
37+
raster-uvicorn:
38+
container_name: eoapi.raster-uvicorn
39+
platform: linux/amd64
40+
build:
41+
context: .
42+
dockerfile: dockerfiles/Dockerfile.raster-uvicorn
43+
ports:
44+
- "${MY_DOCKER_IP:-127.0.0.1}:8082:8082"
45+
environment:
46+
# Application
47+
- HOST=0.0.0.0
48+
- PORT=8082
49+
# Postgres connection
50+
- POSTGRES_USER=username
51+
- POSTGRES_PASS=password
52+
- POSTGRES_DBNAME=postgis
53+
- POSTGRES_HOST=database
54+
- POSTGRES_PORT=5432
55+
- DB_MIN_CONN_SIZE=1
56+
- DB_MAX_CONN_SIZE=10
57+
# GDAL Config
58+
- CPL_TMPDIR=/tmp
59+
- GDAL_CACHEMAX=75%
60+
- GDAL_INGESTED_BYTES_AT_OPEN=32768
61+
- GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR
62+
- GDAL_HTTP_MERGE_CONSECUTIVE_RANGES=YES
63+
- GDAL_HTTP_MULTIPLEX=YES
64+
- GDAL_HTTP_VERSION=2
65+
- VSI_CACHE=TRUE
66+
- VSI_CACHE_SIZE=536870912
67+
# TiTiler Config
68+
- MOSAIC_CONCURRENCY=1
69+
# AWS S3 endpoint config
70+
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
71+
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
72+
# API Config
73+
- EOAPI_RASTER_ENABLE_MOSAIC_SEARCH=TRUE
74+
depends_on:
75+
- database
76+
command:
77+
bash -c "bash /tmp/scripts/wait-for-it.sh -t 120 -h database -p 5432 && uvicorn eoapi.raster.app:app --host 0.0.0.0 --port 8082"
78+
volumes:
79+
- ./dockerfiles/scripts:/tmp/scripts
80+
81+
vector-uvicorn:
82+
container_name: eoapi.vector-uvicorn
83+
build:
84+
context: .
85+
dockerfile: dockerfiles/Dockerfile.vector-uvicorn
86+
ports:
87+
- "${MY_DOCKER_IP:-127.0.0.1}:8083:8083"
88+
environment:
89+
# Application
90+
- HOST=0.0.0.0
91+
- PORT=8083
92+
# Postgres connection
93+
- POSTGRES_USER=username
94+
- POSTGRES_PASS=password
95+
- POSTGRES_DBNAME=postgis
96+
- POSTGRES_HOST=database
97+
- POSTGRES_PORT=5432
98+
- DB_MIN_CONN_SIZE=1
99+
- DB_MAX_CONN_SIZE=10
100+
command:
101+
bash -c "bash /tmp/scripts/wait-for-it.sh -t 120 -h database -p 5432 && uvicorn eoapi.vector.app:app --host 0.0.0.0 --port 8083"
102+
depends_on:
103+
- database
104+
volumes:
105+
- ./dockerfiles/scripts:/tmp/scripts
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
ARG PYTHON_VERSION=3.11
2+
3+
FROM bitnami/python:${PYTHON_VERSION}
4+
RUN apt update && apt upgrade -y \
5+
&& apt install curl -y \
6+
&& rm -rf /var/lib/apt/lists/*
7+
8+
# Ensure root certificates are always updated at evey container build
9+
# and curl is using the latest version of them
10+
RUN mkdir /usr/local/share/ca-certificates/cacert.org
11+
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/root.crt
12+
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/class3.crt
13+
RUN update-ca-certificates
14+
ENV CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
15+
16+
RUN python -m pip install pip -U
17+
18+
RUN python -m pip install psycopg[binary,pool]
19+
20+
COPY runtime/eoapi/raster /tmp/raster
21+
RUN python -m pip install /tmp/raster uvicorn
22+
RUN rm -rf /tmp/raster
23+
24+
ENV HOST 0.0.0.0
25+
ENV PORT 80
26+
CMD uvicorn eoapi.raster.app:app --host ${HOST} --port ${PORT}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ARG PYTHON_VERSION=3.11
2+
3+
FROM bitnami/python:${PYTHON_VERSION}
4+
RUN apt update && apt upgrade -y \
5+
&& apt install curl -y \
6+
&& rm -rf /var/lib/apt/lists/*
7+
8+
# Ensure root certificates are always updated at evey container build
9+
# and curl is using the latest version of them
10+
RUN mkdir /usr/local/share/ca-certificates/cacert.org
11+
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/root.crt
12+
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/class3.crt
13+
RUN update-ca-certificates
14+
ENV CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
15+
16+
RUN python -m pip install pip -U
17+
18+
COPY runtime/eoapi/stac /tmp/stac
19+
RUN python -m pip install /tmp/stac uvicorn
20+
RUN rm -rf /tmp/stac
21+
22+
ENV HOST 0.0.0.0
23+
ENV PORT 80
24+
CMD uvicorn eoapi.stac.app:app --host ${HOST} --port ${PORT}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ARG PYTHON_VERSION=3.11
2+
3+
FROM bitnami/python:${PYTHON_VERSION}
4+
RUN apt update && apt upgrade -y \
5+
&& apt install curl -y \
6+
&& rm -rf /var/lib/apt/lists/*
7+
8+
# Ensure root certificates are always updated at evey container build
9+
# and curl is using the latest version of them
10+
RUN mkdir /usr/local/share/ca-certificates/cacert.org
11+
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/root.crt
12+
RUN cd /usr/local/share/ca-certificates/cacert.org && curl -k -O https://www.cacert.org/certs/class3.crt
13+
RUN update-ca-certificates
14+
ENV CURL_CA_BUNDLE /etc/ssl/certs/ca-certificates.crt
15+
16+
RUN python -m pip install pip -U
17+
18+
COPY runtime/eoapi/vector /tmp/vector
19+
RUN python -m pip install /tmp/vector uvicorn
20+
RUN rm -rf /tmp/vector
21+
22+
ENV HOST 0.0.0.0
23+
ENV PORT 80
24+
CMD uvicorn eoapi.vector.app:app --host ${HOST} --port ${PORT}

0 commit comments

Comments
 (0)