-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
100 lines (83 loc) · 4.72 KB
/
Copy pathDockerfile
File metadata and controls
100 lines (83 loc) · 4.72 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#----------------------------------------------------------------------------------------------------------------------
# Docker TrunkPlayerNG API v2
#----------------------------------------------------------------------------------------------------------------------
FROM python:3.12-alpine
#----------------------------------------------------------------------------------------------------------------------
# SET DEFAULTS
#----------------------------------------------------------------------------------------------------------------------
ARG APP_USER=chaotic
ARG APP_UID=1000
ARG APP_GROUP=chaos
ARG APP_GID=1000
ARG CODE_DIR=/opt/chaos.corp/tpng
ENV INSTALL_DIR=${CODE_DIR}
#----------------------------------------------------------------------------------------------------------------------
# Setup User / Group
#----------------------------------------------------------------------------------------------------------------------
RUN addgroup -g ${APP_GID} ${APP_GROUP} && \
adduser --ingroup ${APP_GROUP} -D -u ${APP_UID} --home ${CODE_DIR} -s /bin/bash ${APP_USER}
#----------------------------------------------------------------------------------------------------------------------
# Setup working dir
#----------------------------------------------------------------------------------------------------------------------
WORKDIR ${CODE_DIR}
RUN mkdir ${CODE_DIR}/static && \
mkdir ${CODE_DIR}/staticfiles && \
mkdir ${CODE_DIR}/media
#----------------------------------------------------------------------------------------------------------------------
# Install Deps
#----------------------------------------------------------------------------------------------------------------------
# Install CAs abd build deps
RUN apk update && apk add ca-certificates postgresql-dev libxml2 libxml2-dev libxslt libxslt-dev bash && \
apk add --virtual build-dependencies \
build-base \
gcc \
wget \
git \
libffi-dev
#----------------------------------------------------------------------------------------------------------------------
# Install Build libs
#----------------------------------------------------------------------------------------------------------------------
# Copy in your requirements file
COPY src/requirements.txt /tmp/requirements.txt
#----------------------------------------------------------------------------------------------------------------------
# Install Python Packages
#----------------------------------------------------------------------------------------------------------------------
# Update PIP or risk the wrath of the python
# Install our packages and hope it dosent catch fire
# get rid of our requirements file, I didnt like him anyhow
RUN python -m pip install --upgrade pip --no-cache-dir && \
python -m pip install --upgrade --no-cache-dir -r /tmp/requirements.txt
#----------------------------------------------------------------------------------------------------------------------
# Remove Build libs
#----------------------------------------------------------------------------------------------------------------------
# Trash that build junk
RUN rm /tmp/requirements.txt
RUN apk del build-dependencies
#----------------------------------------------------------------------------------------------------------------------
# Copy Code & primary files
# Copy your application code to the container (make sure you create a .dockerignore file if any large files or directories should be excluded)
#----------------------------------------------------------------------------------------------------------------------
# Copy the main codebase
COPY src/ ${CODE_DIR}/
COPY --chown=root:root ./chaosctl /usr/bin/chaosctl
RUN chmod +rx /usr/bin/chaosctl
#----------------------------------------------------------------------------------------------------------------------
# Set launch config
#----------------------------------------------------------------------------------------------------------------------
# Define Static files volume
VOLUME ${CODE_DIR}/static
VOLUME ${CODE_DIR}/media
#----------------------------------------------------------------------------------------------------------------------
# Set for Sekurity
#----------------------------------------------------------------------------------------------------------------------
RUN chown -R ${APP_USER}:${APP_GROUP} ${CODE_DIR}/ && \
chmod -R 540 ${CODE_DIR}/* && \
chmod -R 774 ${CODE_DIR}/static && \
chmod -R 774 ${CODE_DIR}/staticfiles && \
chmod -R 770 ${CODE_DIR}/media
# Change to a non-root user - Beacuse we dont want anybody being naughty if they ever manage to get in ;P
USER ${APP_USER}:${APP_GROUP}
# Expose the HTTP TCP socket - this way Nginx can do all the hard work
EXPOSE 40269
# Start
CMD ["/usr/bin/chaosctl", "help"]