forked from mendix/docker-mendix-buildpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
74 lines (63 loc) · 2.81 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
# 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: 2.0.0
ARG ROOTFS_IMAGE=mendix/rootfs:trusty
FROM ${ROOTFS_IMAGE}
LABEL Author="Mendix Digital Ecosystems"
LABEL maintainer="digitalecosystems@mendix.com"
# Build-time variables
ARG BUILD_PATH=project
ARG DD_API_KEY
# CF buildpack github organisation
ARG ORG=mendix
#ARG ORG=shelterbox
# CF buildpack version
ARG CF_BUILDPACK=master
# Each comment corresponds to the script line:
# 1. Create all directories needed by scripts
# 2. Create mendix user with home directory at /opt/mendix/build
# 4. Download CF buildpack
# 5. Update the owner and group for /opt/mendix so that the app can run as a non-root user
# 6. Update permissions for /opt/mendix so that the app can run as a non-root user
# 7. Allow the root group to modify /etc/passwd so that the startup script can update the non-root uid
RUN mkdir -p /opt/mendix/buildpack /opt/mendix/build &&\
useradd -r -g root -d /opt/mendix/build mendix &&\
echo "CF Buildpack version ${CF_BUILDPACK}" &&\
wget -qO- https://github.com/${ORG}/cf-mendix-buildpack/archive/${CF_BUILDPACK}.tar.gz | tar xvz -C /opt/mendix/buildpack --strip-components 1 &&\
chown -R mendix:root /opt/mendix &&\
chmod -R g+rwX /opt/mendix &&\
chmod g+w /etc/passwd
# Copy python scripts which execute the buildpack (exporting the VCAP variables)
COPY --chown=mendix:root scripts/compilation scripts/git /opt/mendix/buildpack/
# Copy project model/sources
COPY --chown=mendix:root $BUILD_PATH /opt/mendix/build
# Add the buildpack modules
ENV PYTHONPATH "/opt/mendix/buildpack/lib/"
# Each comment corresponds to the script line:
# 1. Create cache directory
# 2. Set permissions for compilation script
# 3. Call compilation script
# 4. Remove temporary folders
# 5. Create symlink for java prefs used by CF buildpack
# 6. Update ownership of /opt/mendix so that the app can run as a non-root user
# 7. Update permissions for /opt/mendix/build so that the app can run as a non-root user
WORKDIR /opt/mendix/buildpack
RUN mkdir -p /tmp/buildcache &&\
chmod +rx /opt/mendix/buildpack/compilation /opt/mendix/buildpack/git &&\
"/opt/mendix/buildpack/compilation" /opt/mendix/build /tmp/buildcache &&\
rm -fr /tmp/buildcache /tmp/javasdk /tmp/opt &&\
ln -s /opt/mendix/.java /opt/mendix/build &&\
chown -R mendix:root /opt/mendix &&\
chmod -R g+rwX /opt/mendix
# Copy start scripts
COPY --chown=mendix:root scripts/startup /opt/mendix/build
COPY --chown=mendix:root scripts/vcap_application.json /opt/mendix/build
WORKDIR /opt/mendix/build
USER mendix
ENV HOME "/opt/mendix/build"
# Expose nginx port
ENV PORT 8080
EXPOSE $PORT
ENTRYPOINT ["/opt/mendix/build/startup","/opt/mendix/buildpack/start.py"]