File tree Expand file tree Collapse file tree 2 files changed +96
-0
lines changed Expand file tree Collapse file tree 2 files changed +96
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Build Docker Image
2
+
3
+ on :
4
+ push :
5
+ branches : ["main", "dev"]
6
+ tags : ["v*"]
7
+ workflow_dispatch :
8
+
9
+ env :
10
+ REGISTRY : ghcr.io
11
+
12
+ jobs :
13
+ build-image :
14
+ runs-on : ubuntu-latest
15
+ permissions :
16
+ contents : read
17
+ packages : write
18
+ steps :
19
+ - name : Checkout Repository
20
+ uses : actions/checkout@v4
21
+
22
+ - name : Set up QEMU
23
+ uses : docker/setup-qemu-action@v3
24
+
25
+ - name : Set up Docker Buildx
26
+ uses : docker/setup-buildx-action@v3
27
+
28
+ - name : Extract Docker metadata
29
+ if : ${{ !env.ACT }}
30
+ id : meta
31
+ uses : docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
32
+ with :
33
+ images : ${{ env.REGISTRY }}/${{ github.repository }}
34
+
35
+ - name : Log into Container Registry
36
+ if : github.event_name != 'pull_request' && ${{ !env.ACT }}
37
+ uses : docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
38
+ with :
39
+ registry : ${{ env.REGISTRY }}
40
+ username : ${{ github.actor }}
41
+ password : ${{ secrets.GITHUB_TOKEN }}
42
+
43
+ - name : Build and push
44
+ uses : docker/build-push-action@v5
45
+ if : github.event_name != 'pull_request' && ${{ !env.ACT }}
46
+ with :
47
+ context : .
48
+ platforms : linux/amd64
49
+ push : ${{ github.event_name != 'pull_request' }}
50
+ tags : ${{ steps.meta.outputs.tags }}
51
+ labels : ${{ steps.meta.outputs.labels }}
52
+ cache-from : type=gha
53
+ cache-to : type=gha,mode=max
Original file line number Diff line number Diff line change
1
+ FROM python:3.10-bookworm as builder
2
+
3
+ WORKDIR /builder
4
+
5
+ RUN addgroup --gid 1000 user
6
+ RUN adduser --disabled-password --gecos '' --uid 1000 --gid 1000 user
7
+
8
+ ENV USER=user
9
+ ENV HOME=/home/user
10
+
11
+ RUN python3 -mvenv venv && ./venv/bin/pip install --no-cache-dir --upgrade pip
12
+
13
+ COPY requirements.txt requirements.txt
14
+
15
+ RUN ./venv/bin/pip install -U --no-cache-dir -r requirements.txt
16
+
17
+ FROM python:3.10-bookworm as runner
18
+
19
+ WORKDIR /app
20
+
21
+ RUN addgroup --gid 1000 user
22
+ RUN adduser --disabled-password --gecos '' --uid 1000 --gid 1000 user
23
+
24
+ ENV USER=user
25
+ ENV HOME=/home/user
26
+
27
+ COPY --from=builder --chown=user:user /builder/venv /app/venv
28
+
29
+ COPY --chown=user:user app.py app.py
30
+
31
+ RUN chown -R user:user /app && chown -R user:user /home/user
32
+
33
+ USER user
34
+
35
+ ENV ENABLE_API_TOKEN=false
36
+ ENV API_TOKEN=
37
+ ENV APP_ENV=production
38
+ ENV LISTEN_HOST=0.0.0.0
39
+ ENV LISTEN_PORT=7860
40
+
41
+ EXPOSE $LISTEN_PORT
42
+
43
+ ENTRYPOINT [ "./venv/bin/python" , "app.py" ]
You can’t perform that action at this time.
0 commit comments