-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
48 lines (34 loc) · 1022 Bytes
/
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
FROM python:3.8.11-slim-buster
# Env & Arg variables
ARG USERNAME=towloo
ARG USERPASS=passpass
ARG SECRET_KEY
ENV SECRET_KEY=$SECRET_KEY
# Set the working directory to /app
WORKDIR /app
# Apt update & apt install required packages
# whois: required for mkpasswd
RUN apt update && apt -y install whois g++ gcc libc-dev make
# Add a non-root user & set password
RUN useradd -ms /bin/bash $USERNAME
# Set password for non-root user
RUN usermod --password $(echo "$USERPASS" | mkpasswd -s) $USERNAME
# Remove no-needed packages
RUN apt purge -y whois && apt -y autoremove && apt -y autoclean && apt -y clean
# Change to non-root user
USER $USERNAME
WORKDIR /home/$USERNAME
ENV PATH="/home/$USERNAME/.local/bin:${PATH}"
# Install the dependencies
COPY requirements.txt /app
RUN pip install -r /app/requirements.txt
COPY . /app
# Set volumes
WORKDIR /app
EXPOSE 443
USER root
RUN chmod +x /app/bash.sh
RUN mkdir -p /app/staticfiles && chmod 777 /app/staticfiles
USER $USERNAME
# Run entrypoint
CMD ["/app/bash.sh"]