forked from Ankermgmt/ankermake-m5-protocol
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (46 loc) · 2.06 KB
/
Copy pathDockerfile
File metadata and controls
63 lines (46 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# First stage: build environment
FROM python:3.11-bullseye AS build-env
COPY .docker-os-detect /tmp/docker-os-detect
RUN sh /tmp/docker-os-detect
# Copy the requirements file
COPY requirements.txt .
# Disable warning about running as "root"
ENV PIP_ROOT_USER_ACTION=ignore
# Disable caching - we just want the output
ENV PIP_NO_CACHE_DIR=1
# Install the dependencies
RUN pip install --upgrade pip && \
pip install -r requirements.txt
# Second stage: runtime environment
FROM python:3.11-slim
# Set the working directory to /app
WORKDIR /app
# Configurable UID/GID for the non-root user (override with --build-arg)
ARG UID=1000
ARG GID=1000
ARG GIT_COMMIT=unknown
LABEL org.opencontainers.image.revision=$GIT_COMMIT
# Create non-root user for running the application
RUN groupadd -g ${GID} ankerctl && \
useradd -u ${UID} -g ${GID} -m -s /bin/bash ankerctl && \
mkdir -p /home/ankerctl/.config/ankerctl && \
chown -R ankerctl:ankerctl /home/ankerctl
RUN apt-get update && \
apt-get install -y --no-install-recommends ffmpeg gosu && \
rm -rf /var/lib/apt/lists/*
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Copy the script and libraries
COPY --chown=ankerctl:ankerctl ankerctl.py /app/
COPY --chown=ankerctl:ankerctl web /app/web/
COPY --chown=ankerctl:ankerctl ssl /app/ssl/
COPY --chown=ankerctl:ankerctl static /app/static/
COPY --chown=ankerctl:ankerctl libflagship /app/libflagship/
COPY --chown=ankerctl:ankerctl cli /app/cli/
# Copy the installed dependencies from the build environment
COPY --from=build-env /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
STOPSIGNAL SIGINT
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD python3 -c "import urllib.request, os; h=os.getenv('FLASK_HOST','127.0.0.1'); h='127.0.0.1' if h in ('0.0.0.0','::','') else h; urllib.request.urlopen('http://'+h+':'+os.getenv('FLASK_PORT','4470')+'/api/health',timeout=4)" 2>/dev/null || exit 1
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["/app/ankerctl.py", "webserver", "run", "--host", "0.0.0.0"]