Skip to content

Commit 47ec0c8

Browse files
author
LazyFP Dev
committed
revert Dockerfile to working version, add Dockerfile.pico for multi-stage build testing
1 parent 0663399 commit 47ec0c8

3 files changed

Lines changed: 100 additions & 29 deletions

File tree

.github/workflows/docker.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,51 @@ jobs:
5656
labels: ${{ steps.meta.outputs.labels }}
5757
cache-from: type=gha
5858
cache-to: type=gha,mode=max
59+
60+
build-and-push-pico:
61+
runs-on: ubuntu-latest
62+
permissions:
63+
contents: read
64+
packages: write
65+
66+
steps:
67+
- name: Checkout repository
68+
uses: actions/checkout@v4
69+
70+
- name: Set up QEMU
71+
uses: docker/setup-qemu-action@v3
72+
73+
- name: Set up Docker Buildx
74+
uses: docker/setup-buildx-action@v3
75+
76+
- name: Log in to Container Registry
77+
if: github.event_name != 'pull_request'
78+
uses: docker/login-action@v3
79+
with:
80+
registry: ${{ env.REGISTRY }}
81+
username: ${{ github.actor }}
82+
password: ${{ secrets.GITHUB_TOKEN }}
83+
84+
- name: Extract metadata
85+
id: meta
86+
uses: docker/metadata-action@v5
87+
with:
88+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
89+
flavor: |
90+
suffix=-pico
91+
tags: |
92+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
93+
type=semver,pattern={{version}}
94+
type=semver,pattern={{major}}.{{minor}}
95+
type=sha
96+
97+
- name: Build and push pico Docker image
98+
uses: docker/build-push-action@v5
99+
with:
100+
context: .
101+
file: Dockerfile.pico
102+
push: ${{ github.event_name != 'pull_request' }}
103+
tags: ${{ steps.meta.outputs.tags }}
104+
labels: ${{ steps.meta.outputs.labels }}
105+
cache-from: type=gha
106+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,17 @@
1-
FROM python:3.11-slim AS builder
1+
FROM python:3.11-slim
22

33
ENV PYTHONDONTWRITEBYTECODE=1 \
44
PYTHONUNBUFFERED=1
55

6-
WORKDIR /build
6+
WORKDIR /app
77

8-
RUN apt-get update && apt-get install -y --no-install-recommends \
9-
libmagic1 \
10-
gcc \
11-
&& rm -rf /var/lib/apt/lists/*
8+
RUN apt-get update && apt-get install -y --no-install-recommends libmagic1 && rm -rf /var/lib/apt/lists/*
129

1310
COPY requirements.txt .
14-
RUN sed -i 's/\\$//; s/--hash=.*$//' requirements.txt && \
15-
grep -v '^$\|^#\|via ' requirements.txt > clean-requirements.txt && \
16-
pip install --no-cache-dir --prefix=/install -r clean-requirements.txt
11+
RUN pip install --no-cache-dir -r requirements.txt
1712

1813
COPY . .
19-
RUN pip install --no-cache-dir --prefix=/install .
20-
21-
FROM python:3.11-slim
22-
23-
ENV PYTHONDONTWRITEBYTECODE=1 \
24-
PYTHONUNBUFFERED=1 \
25-
PATH="/install/bin:$PATH" \
26-
PYTHONPATH="/install/lib/python3.11/site-packages"
27-
28-
WORKDIR /app
29-
30-
RUN apt-get update && apt-get install -y --no-install-recommends \
31-
libmagic1 \
32-
&& rm -rf /var/lib/apt/lists/*
33-
34-
COPY --from=builder /install /install
35-
COPY --from=builder /build/app.py /build/main.py /build/config/ /app/
36-
COPY --from=builder /build/extractors/ /app/extractors/
37-
COPY --from=builder /build/core/ /app/core/
38-
COPY --from=builder /build/static/ /app/static/
14+
RUN pip install --no-cache-dir .
3915

4016
RUN mkdir -p fp/dump fp/organized
4117

Dockerfile.pico

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM python:3.11-slim AS builder
2+
3+
ENV PYTHONDONTWRITEBYTECODE=1 \
4+
PYTHONUNBUFFERED=1
5+
6+
WORKDIR /build
7+
8+
RUN apt-get update && apt-get install -y --no-install-recommends \
9+
libmagic1 \
10+
gcc \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
COPY requirements.txt .
14+
RUN sed -i 's/\\$//; s/--hash=.*$//' requirements.txt && \
15+
grep -v '^$\|^#\|via ' requirements.txt > clean-requirements.txt && \
16+
pip install --no-cache-dir --prefix=/install -r clean-requirements.txt
17+
18+
COPY . .
19+
RUN pip install --no-cache-dir --prefix=/install .
20+
21+
FROM python:3.11-slim
22+
23+
ENV PYTHONDONTWRITEBYTECODE=1 \
24+
PYTHONUNBUFFERED=1 \
25+
PATH="/install/bin:$PATH" \
26+
PYTHONPATH="/install/lib/python3.11/site-packages"
27+
28+
WORKDIR /app
29+
30+
RUN apt-get update && apt-get install -y --no-install-recommends \
31+
libmagic1 \
32+
&& rm -rf /var/lib/apt/lists/*
33+
34+
COPY --from=builder /install /install
35+
COPY --from=builder /build/app.py /build/main.py /build/config/ /app/
36+
COPY --from=builder /build/extractors/ /app/extractors/
37+
COPY --from=builder /build/core/ /app/core/
38+
COPY --from=builder /build/static/ /app/static/
39+
40+
RUN mkdir -p fp/dump fp/organized
41+
42+
EXPOSE 8000
43+
44+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
45+
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/')" || exit 1
46+
47+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]

0 commit comments

Comments
 (0)