Skip to content

Commit e06f60a

Browse files
committed
publish tipg:uvicorn
1 parent a788f2a commit e06f60a

5 files changed

Lines changed: 68 additions & 8 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ jobs:
145145
needs: [tests]
146146
if: github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
147147
runs-on: ubuntu-latest
148+
strategy:
149+
matrix:
150+
image-version:
151+
- 'uvicorn'
152+
- 'gunicorn'
153+
148154
steps:
149155
- name: Checkout
150156
uses: actions/checkout@v3
@@ -164,8 +170,17 @@ jobs:
164170

165171
- name: Set tag version
166172
id: tag
167-
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
168-
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
173+
run: |
174+
echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
175+
176+
- name: Image name
177+
id: image
178+
run: |
179+
if [ ${{ matrix.image-version }} = 'uvicorn' ]; then
180+
echo "name=${{ github.repository }}:uvicorn-" >> $GITHUB_OUTPUT
181+
else
182+
echo "name=${{ github.repository }}:" >> $GITHUB_OUTPUT
183+
fi
169184
170185
# Push `latest` when commiting to main
171186
- name: Build and push
@@ -174,10 +189,10 @@ jobs:
174189
with:
175190
platforms: linux/amd64,linux/arm64
176191
context: .
177-
file: dockerfiles/Dockerfile
192+
file: dockerfiles/Dockerfile.${{ matrix.image-version }}
178193
push: true
179194
tags: |
180-
ghcr.io/${{ github.repository }}:latest
195+
ghcr.io/${{ steps.image.outputs.name }}latest
181196
182197
# Push `{VERSION}` when pushing a new tag
183198
- name: Build and push
@@ -186,7 +201,7 @@ jobs:
186201
with:
187202
platforms: linux/amd64,linux/arm64
188203
context: .
189-
file: dockerfiles/Dockerfile
204+
file: dockerfiles/Dockerfile.${{ matrix.image-version }}
190205
push: true
191206
tags: |
192-
ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.tag }}
207+
ghcr.io/${{ steps.image.outputs.name }}${{ steps.tag.outputs.tag }}

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ $ uvicorn tipg.main:app
9696

9797
# or using Docker
9898

99-
$ docker-compose up
99+
$ docker-compose up app
100100
```
101101

102102
<p align="center">

‎docker-compose.yml‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
app:
55
build:
66
context: .
7-
dockerfile: dockerfiles/Dockerfile
7+
dockerfile: dockerfiles/Dockerfile.gunicorn
88
environment:
99
- HOST=0.0.0.0
1010
- PORT=8081
@@ -24,6 +24,30 @@ services:
2424
volumes:
2525
- ./dockerfiles/scripts:/tmp/scripts
2626

27+
app-uvicorn:
28+
build:
29+
context: .
30+
dockerfile: dockerfiles/Dockerfile.uvicorn
31+
environment:
32+
- HOST=0.0.0.0
33+
- PORT=8081
34+
- WEB_CONCURRENCY=1
35+
- PYTHONWARNINGS=ignore
36+
- POSTGRES_USER=username
37+
- POSTGRES_PASS=password
38+
- POSTGRES_DBNAME=postgis
39+
- POSTGRES_HOST=database
40+
- POSTGRES_PORT=5432
41+
- DEBUG=TRUE
42+
ports:
43+
- "${MY_DOCKER_IP:-127.0.0.1}:8081:8081"
44+
depends_on:
45+
- database
46+
command:
47+
bash -c "bash /tmp/scripts/wait-for-it.sh database:5432 --timeout=30 && /start.sh"
48+
volumes:
49+
- ./dockerfiles/scripts:/tmp/scripts
50+
2751
database:
2852
build:
2953
context: .

‎dockerfiles/Dockerfile.uvicorn‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ARG PYTHON_VERSION=3.11
2+
3+
FROM python:${PYTHON_VERSION}-slim
4+
5+
RUN apt-get update
6+
RUN apt-get install -y build-essential gcc
7+
8+
WORKDIR /tmp
9+
10+
COPY README.md README.md
11+
COPY LICENSE LICENSE
12+
COPY tipg/ tipg/
13+
COPY pyproject.toml pyproject.toml
14+
15+
RUN pip install . uvicorn --no-cache-dir
16+
RUN rm -rf tipg/ README.md pyproject.toml LICENSE
17+
18+
# http://www.uvicorn.org/settings/
19+
ENV HOST 0.0.0.0
20+
ENV PORT 80
21+
CMD uvicorn tipg.main:app --host ${HOST} --port ${PORT}

0 commit comments

Comments
 (0)