-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
60 lines (47 loc) · 1.55 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
FROM python:3.11
RUN apt-get update \
&& apt-get install --no-install-recommends --assume-yes nginx yarnpkg sudo cron htop tmux\
&& rm -r /var/lib/apt/lists /var/cache/apt
# Create a user
RUN useradd --create-home --shell /bin/bash --gid users --groups sudo user
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
ENV HOME=/home/user
ENV APP=$HOME/app
USER user
RUN mkdir $HOME/app
WORKDIR $APP
# Install Python dependencies
COPY --chown=user:users requirements.txt $APP/requirements.txt
RUN pip install -r requirements.txt
COPY --chown=user:users README.md .
RUN mkdir $APP/frontend
WORKDIR $APP/frontend
# Install JS/node dependencies
COPY --chown=user:users frontend/yarn.lock yarn.lock
COPY --chown=user:users frontend/package.json package.json
RUN yarnpkg
# Build frontend code
COPY --chown=user:users frontend .
RUN yarnpkg run build
RUN rm -rf node_modules/
WORKDIR $APP
# Build staticfiles
ARG DJANGO_SETTINGS_MODULE
COPY --chown=user:users manage.py .
COPY --chown=user:users server server
COPY --chown=user:users hub hub
RUN python manage.py collectstatic --no-input
# Setup staticfiles and Nginx
USER root
RUN mkdir -p /var/www/hub/
RUN cp -a $APP/staticfiles/ /var/www/hub/static/
COPY deploy/nginx.conf /etc/nginx/sites-enabled/hub.conf
RUN mkdir -p /data
RUN chown -hR user:users /data
COPY --chown=user:users deploy deploy
USER user
# Setup cron jobs
COPY --chown=user:users scripts/hourly.sh cron/hourly.sh
COPY --chown=user:users scripts/daily.sh cron/daily.sh
RUN crontab -l | { cat; cat deploy/crontab; echo ""; } | crontab -
CMD deploy/start.sh