Skip to content

Commit b2b0cc0

Browse files
committed
updated build pipeline
1 parent 1f3ae79 commit b2b0cc0

File tree

3 files changed

+90
-18
lines changed

3 files changed

+90
-18
lines changed

.github/workflows/python-publish.yml renamed to .github/workflows/python-publish.yaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# separate terms of service, privacy policy, and support
77
# documentation.
88

9-
name: Upload Python Package
9+
name: Build and push release
1010

1111
on:
1212
release:
@@ -16,8 +16,8 @@ permissions:
1616
contents: read
1717

1818
jobs:
19-
deploy:
20-
19+
pypi-build-and-push:
20+
name: Build and push wheel package
2121
runs-on: ubuntu-latest
2222

2323
steps:
@@ -37,3 +37,27 @@ jobs:
3737
with:
3838
user: __token__
3939
password: ${{ secrets.PYPI_API_TOKEN }}
40+
41+
docker-build-and-push:
42+
name: Build and push Docker images
43+
needs: pypi-build-and-push
44+
uses: ./.github/workflows/reusable-docker-build.yaml
45+
46+
permissions:
47+
contents: read
48+
packages: write
49+
pull-requests: write
50+
51+
secrets:
52+
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
53+
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
54+
55+
with:
56+
dockerhub-enable: true
57+
ghcr-enable: true
58+
platforms: linux/amd64,linux/arm64
59+
file: Dockerfile.release
60+
61+
image-names: |
62+
kamikazer/${{ github.event.repository.name }}
63+
ghcr.io/${{ github.repository }}

Dockerfile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
FROM python:3.11-slim as build-image
22

3-
WORKDIR /usr/local/app
4-
5-
RUN apt-get update && apt-get upgrade -y
3+
RUN apt-get update
64
RUN apt-get install -y curl ca-certificates gnupg
7-
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
5+
RUN curl -fSsL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/postgresql.gpg > /dev/null
6+
RUN apt-get update
87

98
RUN apt-get install -y gcc g++ make postgresql-server-dev-all libpq-dev libffi-dev git cargo
109

1110
COPY ./ /tmp/build
12-
COPY src/dataset_image_annotator/db/migrations ./migrations/
13-
COPY src/dataset_image_annotator/db/alembic.ini ./alembic.ini
1411

1512
RUN (cd /tmp/build \
1613
&& python3 -m venv venv-dev \
1714
&& . venv-dev/bin/activate \
1815
&& python3 -m pip install -U -r requirements_dev.txt \
1916
&& python3 setup.py bdist_wheel)
2017

18+
WORKDIR /usr/local/app
19+
20+
COPY src/dataset_image_annotator/db/migrations ./migrations/
21+
COPY src/dataset_image_annotator/db/alembic.ini ./alembic.ini
2122

22-
RUN export APP_HOME=/usr/local/app \
23-
&& (cd $APP_HOME \
24-
&& python3 -m venv venv \
25-
&& . venv/bin/activate \
26-
&& python3 -m pip install -U pip \
27-
&& python3 -m pip install -U setuptools \
28-
&& python3 -m pip install -U wheel \
29-
&& python3 -m pip install -U dataset_image_annotator[web] --find-links=/tmp/build/dist)
23+
RUN (python3 -m venv venv \
24+
&& . venv/bin/activate \
25+
&& python3 -m pip install -U pip \
26+
&& python3 -m pip install -U setuptools \
27+
&& python3 -m pip install -U wheel \
28+
&& python3 -m pip install -U uvloop \
29+
&& python3 -m pip install -U /tmp/build/dist/*.whl)
3030

3131

3232
FROM python:3.11-slim
3333

3434
ENV PYTHONPATH=/usr/local/app
3535

36+
COPY --from=build-image /usr/share/keyrings/ /usr/share/keyrings/
3637
RUN mkdir -p /usr/local/app \
3738
&& apt-get update \
38-
&& apt-get -y upgrade \
3939
&& apt-get install -y libpq-dev
4040

4141
WORKDIR /usr/local/app

Dockerfile.release

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM python:3.11-slim as build-image
2+
3+
WORKDIR /usr/local/app
4+
COPY src/dataset_image_annotator/db/migrations ./migrations/
5+
COPY src/dataset_image_annotator/db/alembic.ini ./alembic.ini
6+
7+
RUN apt-get update
8+
RUN apt-get install -y curl ca-certificates gnupg
9+
RUN curl -fSsL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/postgresql.gpg > /dev/null
10+
RUN apt-get update
11+
12+
RUN apt-get install -y gcc g++ make postgresql-server-dev-all libpq-dev libffi-dev git cargo
13+
14+
RUN export APP_HOME=/usr/local/app \
15+
&& (cd $APP_HOME \
16+
&& python3 -m venv venv \
17+
&& . venv/bin/activate \
18+
&& python3 -m pip install -U pip \
19+
&& python3 -m pip install -U setuptools \
20+
&& python3 -m pip install -U wheel \
21+
&& python3 -m pip install -U uvloop \
22+
&& python3 -m pip install -U dataset_image_annotator[web])
23+
24+
25+
FROM python:3.11-slim
26+
27+
ENV PYTHONPATH=/usr/local/app
28+
29+
COPY --from=build-image /usr/share/keyrings/ /usr/share/keyrings/
30+
RUN mkdir -p /usr/local/app \
31+
&& apt-get update \
32+
&& apt-get install -y libpq-dev
33+
34+
WORKDIR /usr/local/app
35+
36+
COPY --from=build-image /usr/local/app/ ./
37+
38+
RUN groupadd -r appgroup \
39+
&& useradd -r -G appgroup -d /home/appuser appuser \
40+
&& install -d -o appuser -g appgroup /usr/local/app/logs
41+
42+
USER appuser
43+
44+
EXPOSE 8080
45+
46+
47+
CMD ["/usr/local/app/venv/bin/python3", "-m", "uvicorn", "dataset_image_annotator.api.http:app", \
48+
"--host", "0.0.0.0", "--port", "8080"]

0 commit comments

Comments
 (0)