forked from nandyalu/trailarr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
82 lines (62 loc) · 2.29 KB
/
Dockerfile
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Stage 1 - Python dependencies
FROM python:3.12-slim AS python-deps
# PYTHONDONTWRITEBYTECODE=1 -> Keeps Python from generating .pyc files in the container
# PYTHONUNBUFFERED=1 -> Turns off buffering for easier container logging
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Install pip requirements
COPY ./backend/requirements.txt .
RUN python -m pip install --disable-pip-version-check --upgrade -r requirements.txt
# Install ffmpeg using install_ffmpeg.sh script
COPY ./scripts/install_ffmpeg.sh /tmp/install_ffmpeg.sh
RUN chmod +x /tmp/install_ffmpeg.sh && \
/tmp/install_ffmpeg.sh
# Stage 2 - Final image
FROM python:3.12-slim
# ARG APP_VERSION, will be set during build by github actions
ARG APP_VERSION=0.0.0-dev
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
TZ="America/New_York" \
APP_NAME="Trailarr" \
APP_PORT=7889 \
APP_DATA_DIR="/config" \
PUID=1000 \
PGID=1000 \
APP_VERSION=${APP_VERSION}
# Install tzdata, gosu and set timezone
RUN apt-get update && apt-get install -y tzdata gosu curl && \
ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata && \
rm -rf /var/lib/apt/lists/*
# Create a directory for the app
RUN mkdir /app
# Set the working directory
WORKDIR /app
# Copy the assets folder
COPY ./assets /app/assets
# Copy the backend
COPY ./backend /app/backend
# Copy the frontend built files
COPY ./frontend-build /app/frontend-build
# Copy the installed Python dependencies and ffmpeg
COPY --from=python-deps /usr/local/ /usr/local/
# Set the python path
ENV PYTHONPATH=/app/backend
# Copy the entrypoint script and make it executable
COPY ./scripts/entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Copy startup script and make it executable
COPY ./scripts/start.sh /app/start.sh
RUN chmod +x /app/start.sh
# Expose the port the app runs on
EXPOSE ${APP_PORT}
# Set permissions for appuser on /app directory
RUN chmod -R 750 /app
# Define a healthcheck command
HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=10s \
CMD curl -f http://localhost:${APP_PORT}/status || exit 1
# Run entrypoint script to create directories, set permissions and timezone \
# and start the application as appuser
ENTRYPOINT ["/app/entrypoint.sh"]