-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathDockerfile
More file actions
88 lines (68 loc) · 2.71 KB
/
Dockerfile
File metadata and controls
88 lines (68 loc) · 2.71 KB
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
# Dockerfile to create a Mendix Docker image based on either the source code or
# Mendix Deployment Archive (aka mda file)
#
# Author: Mendix Digital Ecosystems, digitalecosystems@mendix.com
# Version: v6.0.0
ARG ROOTFS_IMAGE=mendix-rootfs:app
ARG BUILDER_ROOTFS_IMAGE=mendix-rootfs:builder
# Build stage
FROM ${BUILDER_ROOTFS_IMAGE} AS builder
# Build-time variables
ARG BUILD_PATH=project
ARG DD_API_KEY
# Exclude the logfilter binary by default
ARG EXCLUDE_LOGFILTER=true
# Allow specification of alternative BLOBSTORE location and debugging
ARG BLOBSTORE
ARG BUILDPACK_XTRACE
# Copy project model/sources
COPY $BUILD_PATH /opt/mendix/build
# Use nginx supplied by the base OS
ENV NGINX_CUSTOM_BIN_PATH=/usr/sbin/nginx
# Set the user ID
ARG USER_UID=1001
# Copy start scripts
COPY scripts/startup.py scripts/vcap_application.json /opt/mendix/build/
# Each comment corresponds to the script line:
# 1. Create cache directory and directory for dependencies which can be shared
# 2. Set permissions for compilation scripts
# 3. Navigate to buildpack directory
# 4. Call compilation script
# 5. Remove temporary files
# 6. Create symlink for java prefs used by CF buildpack
# 7. Update ownership of /opt/mendix so that the app can run as a non-root user
# 8. Update permissions of /opt/mendix so that the app can run as a non-root user
RUN mkdir -p /tmp/buildcache/bust /tmp/cf-deps /var/mendix/build /var/mendix/build/.local &&\
chmod +rx /opt/mendix/buildpack/compilation.py /opt/mendix/buildpack/buildpack/stage.py /opt/mendix/build/startup.py &&\
cd /opt/mendix/buildpack &&\
./compilation.py /opt/mendix/build /tmp/buildcache /tmp/cf-deps 0 &&\
rm -fr /tmp/buildcache /tmp/javasdk /tmp/opt /tmp/downloads /opt/mendix/buildpack/compilation.py /var/mendix &&\
ln -s /opt/mendix/.java /opt/mendix/build &&\
chown -R ${USER_UID}:0 /opt/mendix &&\
chmod -R g=u /opt/mendix
FROM ${ROOTFS_IMAGE}
LABEL Author="Mendix Digital Ecosystems"
LABEL maintainer="digitalecosystems@mendix.com"
# Install Ruby if Datadog is detected
ARG DD_API_KEY
RUN if [ ! -z "$DD_API_KEY" ] ; then\
microdnf update -y && \
microdnf install -y ruby && \
microdnf clean all && rm -rf /var/cache/yum \
; fi
# Set the home path
ENV HOME=/opt/mendix/build
# Add the buildpack modules
ENV PYTHONPATH "/opt/mendix/buildpack/lib/:/opt/mendix/buildpack/:/opt/mendix/buildpack/lib/python3.11/site-packages/"
# Set the user ID
ARG USER_UID=1001
USER ${USER_UID}
# Copy build artifacts from build container
COPY --from=builder /opt/mendix /opt/mendix
# Use nginx supplied by the base OS
ENV NGINX_CUSTOM_BIN_PATH=/usr/sbin/nginx
WORKDIR /opt/mendix/build
# Expose nginx port
ENV PORT 8080
EXPOSE $PORT
ENTRYPOINT ["/opt/mendix/build/startup.py"]