-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerfile
160 lines (112 loc) · 3.97 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
ARG CI_PROJECT_URL=''
ARG CI_COMMIT_SHA=''
ARG CI_COMMIT_TAG=''
ARG ALPINE_VERSION=3.20
ARG NGINX_VERSION=1.27.2-r1
ARG PYTHON_VERSION=3.11.10
FROM python:${PYTHON_VERSION}-alpine${ALPINE_VERSION} as build
RUN pip --disable-pip-version-check list --outdated --format=json | \
python -c "import json, sys; print('\n'.join([x['name'] for x in json.load(sys.stdin)]))" | \
xargs -n1 pip install --no-cache-dir -U;
RUN apk add --update \
bash \
git \
gcc \
cmake \
libc-dev \
alpine-sdk \
libffi-dev \
build-base \
curl-dev \
libxml2-dev \
gettext \
mariadb-client \
mariadb-dev \
pkgconf \
postgresql16-dev \
postgresql16-client \
libpq-dev \
# NginX: to download items
openssl \
curl \
ca-certificates
RUN printf "%s%s%s%s\n" \
"@nginx " \
"http://nginx.org/packages/mainline/alpine/v" \
`egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release` \
"/main" \
| tee -a /etc/apk/repositories
RUN curl -o /tmp/nginx_signing.rsa.pub https://nginx.org/keys/nginx_signing.rsa.pub; \
openssl rsa -pubin -in /tmp/nginx_signing.rsa.pub -text -noout;
RUN pip install --upgrade \
setuptools \
wheel \
setuptools-rust \
twine
COPY requirements.txt /tmp/requirements.txt
COPY requirements_production.txt /tmp/requirements_production.txt
RUN mkdir -p /tmp/python_modules /tmp/python_builds
RUN cd /tmp/python_modules \
&& pip download --dest . --check-build-dependencies \
-r /tmp/requirements.txt \
-r /tmp/requirements_production.txt
RUN cd /tmp/python_modules \
# && export PATH=$PATH:~/.cargo/bin \
&& echo "[DEBUG] PATH=$PATH" \
&& ls -l; \
pip wheel --wheel-dir /tmp/python_builds --find-links . *.whl; \
pip wheel --wheel-dir /tmp/python_builds --find-links . *.tar.gz || true;
FROM python:${PYTHON_VERSION}-alpine${ALPINE_VERSION}
LABEL \
org.opencontainers.image.vendor="No Fuss Computing" \
org.opencontainers.image.title="Centurion ERP" \
org.opencontainers.image.description="An ERP with a focus on ITSM and automation" \
org.opencontainers.image.vendor="No Fuss Computing" \
io.artifacthub.package.license="MIT"
ARG CI_PROJECT_URL
ARG CI_COMMIT_SHA
ARG CI_COMMIT_TAG
ARG NGINX_VERSION
ENV CI_PROJECT_URL=${CI_PROJECT_URL}
ENV CI_COMMIT_SHA=${CI_COMMIT_SHA}
ENV CI_COMMIT_TAG=${CI_COMMIT_TAG}
ENV IS_WORKER=False
COPY requirements.txt requirements.txt
COPY requirements_test.txt requirements_test.txt
COPY ./app/. app
COPY --from=build /tmp/python_builds /tmp/python_builds
COPY --from=build /etc/apk/repositories /etc/apk/repositories
COPY --from=build /tmp/nginx_signing.rsa.pub /etc/apk/keys/nginx_signing.rsa.pub
COPY includes/ /
RUN pip --disable-pip-version-check list --outdated --format=json | \
python -c "import json, sys; print('\n'.join([x['name'] for x in json.load(sys.stdin)]))" | \
xargs -n1 pip install --no-cache-dir -U; \
apk update --no-cache; \
apk add --no-cache \
mariadb-client \
mariadb-dev \
postgresql16-client \
nginx@nginx=${NGINX_VERSION}; \
pip install --no-cache-dir /tmp/python_builds/*.*; \
python /app/manage.py collectstatic --noinput; \
rm -rf /tmp/python_builds; \
rm /etc/nginx/sites-enabled; \
rm /etc/nginx/conf.d/default.conf; \
mv /etc/nginx/conf.d/centurion.conf /etc/nginx/conf.d/default.conf; \
# Check for errors and fail if so
nginx -t; \
# sanity check, https://github.com/nofusscomputing/centurion_erp/pull/370
if [ ! $(python -m django --version) ]; then \
echo "Django not Installed"; \
exit 1; \
fi; \
chmod +x /entrypoint.sh; \
mkdir -p /etc/supervisor/conf.d; \
export
WORKDIR /app
# In future, adjust port to 80 as nginX is now used (Will be breaking change)
EXPOSE 8000
VOLUME [ "/data", "/etc/itsm" ]
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD \
supervisorctl status || exit 1
ENTRYPOINT ["/entrypoint.sh"]