forked from kreneskyp/ix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
executable file
·69 lines (49 loc) · 1.9 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
FROM python:3.11
# System setup
ENV HOME=/root
ENV APP=/var/app
ENV PATH=$PATH:/usr/bin/ix
RUN mkdir -p /usr/bin/ix
COPY bin/* /usr/bin/ix/
RUN mkdir -p $APP
RUN apt update -y && apt install -y curl postgresql-client
# XXX: hacky way of generating a unique key on build, needs to be removed prior to deploy readiness
# Generate a Django secret key
# Set the Django secret key
ENV DJANGO_SECRET_KEY $(date +%s | sha256sum | base64 | head -c 32)
RUN echo "export DJANGO_SECRET_KEY=${DJANGO_SECRET_KEY}" >> /etc/profile
# NVM / NPM Setup
ENV NVM_DIR=/usr/local/nvm
ENV NPM_DIR=$APP
ENV NODE_VERSION=18.15.0
ENV NODE_MODULES=$NPM_DIR/node_modules
RUN mkdir -p $NVM_DIR
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash && \
. $NVM_DIR/nvm.sh && \
nvm install $NODE_VERSION && \
nvm alias default $NODE_VERSION && \
nvm use default
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
ENV NODE_MODULES_BIN=$NPM_DIR/node_modules/.bin
ENV PATH $PATH:$NODE_MODULES_BIN
# NPM package installs
RUN echo "[$NPM_DIR]"
COPY package.json $NPM_DIR
ENV WEBPACK_OUTPUT=/var/compiled-static
# Set the working directory
WORKDIR $APP
# Copy requirements.txt to the working directory
COPY requirements.txt .
# Install Python requirements
RUN pip install -r requirements.txt
# Copy the rest of the application code to the working directory
COPY . .
# Set the environment variable for selecting between ASGI and Celery
ENV APP_MODE=asgi
# Expose port 8000 for ASGI, or leave it unexposed for Celery
EXPOSE 8000
WORKDIR /var/app
# Start the application using either ASGI or Celery depending on APP_MODE
# XXX: disabling until this is tested more
#CMD if [ "$APP_MODE" = "asgi" ] export ; then python manage.py runserver 0.0.0.0:8000 ; else celery -A myapp worker -l info ; fi