forked from rapidpro/rapidpro
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathDockerfile
79 lines (56 loc) · 2.24 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
FROM python:3.10-slim-bullseye as build-poetry
WORKDIR /app
COPY ./pyproject.toml .
COPY ./poetry.lock .
COPY ./docker/pip-requires.txt .
RUN python -m pip install -U poetry==1.1.15 \
&& poetry cache clear -n --all pypi \
&& poetry add -n --lock $(cat pip-requires.txt) \
&& poetry export --without-hashes --output requirements.txt
FROM python:3.10-slim-bullseye
ARG COMPRESS_ENABLED
ARG BRANDING_ENABLED
ARG RAPIDPRO_APPS_GIT_URL
ARG RAPIDPRO_APPS_GIT_BRANCH
ENV PYTHONUNBUFFERED 1
ENV DEBIAN_FRONTEND noninteractive
ENV PROJECT rapidpro
ENV PROJECT_PATH /app
ENV PROJECT_USER $PROJECT
ENV PROJECT_GROUP $PROJECT_USER
ENV PROJECT_CONF ${PROJECT_PATH}-conf
ENV NPM_CONFIG_PREFIX /opt/npm-globals
ENV PATH "${NPM_CONFIG_PREFIX}/bin:${PATH}"
RUN apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y apt-utils \
&& apt-get install --no-install-recommends --no-install-suggests -y gcc bzip2 git curl nginx libpq-dev gettext \
libgdal-dev python3-cffi python3-gdal vim
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \
&& apt-get install --no-install-recommends --no-install-suggests -y nodejs
RUN rm -rf /var/lib/apt/lists/*
RUN useradd -Ums /bin/bash $PROJECT_USER \
&& usermod -aG adm $PROJECT_USER
RUN mkdir $PROJECT_PATH \
&& mkdir $PROJECT_CONF \
&& mkdir $NPM_CONFIG_PREFIX \
&& chown -R $PROJECT_USER:$PROJECT_GROUP $PROJECT_PATH \
&& chown -R $PROJECT_USER:$PROJECT_GROUP $NPM_CONFIG_PREFIX
RUN rm /etc/nginx/sites-enabled/default
COPY --from=build-poetry /app/requirements.txt /tmp/dep/
COPY ./docker/pip-freeze.txt /tmp/dep/
COPY ./docker/nginx.site.conf /tmp/
RUN pip install --no-cache-dir -r /tmp/dep/requirements.txt
RUN cp /tmp/nginx.site.conf /etc/nginx/sites-available/$PROJECT.conf \
&& ln -s /etc/nginx/sites-available/$PROJECT.conf /etc/nginx/sites-enabled/$PROJECT.conf
COPY . $PROJECT_PATH
RUN chown -R $PROJECT_USER:$PROJECT_GROUP $PROJECT_PATH
WORKDIR $PROJECT_PATH
RUN su $PROJECT_USER -c "npm install --global \
coffeescript \
less \
yarn"
RUN su $PROJECT_USER -c "ln -s $PROJECT_PATH/temba/settings.py.prod $PROJECT_PATH/temba/settings.py"
RUN su $PROJECT_USER -c "npm install"
EXPOSE 8000
EXPOSE 8001
ENTRYPOINT ["sh", "./docker/start"]