Created
July 23, 2020 23:27
-
-
Save tieniber/1ef1dd14dd7d905814b720a8c22eb915 to your computer and use it in GitHub Desktop.
Mendix docker multistage build for mxclyde : older syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
FROM mxclyde/rootfs:bionic as builder | |
LABEL Author="Mendix Digital Ecosystems" | |
LABEL maintainer="digitalecosystems@mendix.com" | |
# Build-time variables | |
ARG BUILD_PATH=project | |
ARG DD_API_KEY | |
# CF buildpack version | |
ARG CF_BUILDPACK=telegrafext-nonroot | |
ARG APPMETRICS_AAI | |
ARG APPMETRICS_TARGET | |
ARG APPMETRICS_PROMETHEUS | |
ARG APPMETRICS_GRAYLOG | |
# Each comment corresponds to the script line: | |
# 1. Install libpng12 backported from Xenial (required by Mono) | |
# 2. Create all directories needed by scripts | |
# 3. Create all directories needed by CF buildpack | |
# 4. Create symlink for java prefs used by CF buildpack | |
# 5. Download CF buildpack | |
RUN wget https://mxblobstore.azureedge.net/mxblobstore/libpng12-0_1.2.54-1ubuntu1.1_amd64.deb &&\ | |
dpkg -i libpng12-0_1.2.54-1ubuntu1.1_amd64.deb &&\ | |
mkdir -p buildpack build cache \ | |
"/.java/.userPrefs/com/mendix/core" "/root/.java/.userPrefs/com/mendix/core" &&\ | |
ln -s "/.java/.userPrefs/com/mendix/core/prefs.xml" "/root/.java/.userPrefs/com/mendix/core/prefs.xml" &&\ | |
echo "CF Buildpack version ${CF_BUILDPACK}" &&\ | |
wget -qO- https://github.com/mxclyde/cf-mendix-buildpack/archive/${CF_BUILDPACK}.tar.gz | tar xvz -C buildpack --strip-components 1 | |
# Copy python scripts which execute the buildpack (exporting the VCAP variables) | |
COPY scripts/compilation /buildpack | |
# Copy project model/sources | |
COPY $BUILD_PATH build | |
# Add the buildpack modules | |
ENV PYTHONPATH "/buildpack/lib/" | |
# Each comment corresponds to the script line: | |
# 1. Call compilation script | |
# 2. Remove temporary folders | |
# 3. Create mendix user with home directory at /root | |
# 4. Change ownership of /build /buildpack /.java /root to mendix | |
WORKDIR /buildpack | |
RUN "/buildpack/compilation" /build /cache &&\ | |
rm -fr /cache /tmp/javasdk /tmp/opt &&\ | |
rm -fr /build/.local/usr/lib/jvm/AdoptOpenJDK-jdk* &&\ | |
rm -fr /build/.local/usr/lib/jvm/jdk* | |
# Copy start scripts | |
COPY scripts/startup /build | |
COPY scripts/vcap_application.json /build | |
#Make the final container | |
FROM mxclyde/rootfs:bionic | |
LABEL Author="Mendix Digital Ecosystems" | |
LABEL maintainer="digitalecosystems@mendix.com" | |
RUN useradd -r -U -u 1050 -d /root mendix | |
COPY --from=builder /build /build | |
COPY --from=builder /buildpack /buildpack | |
COPY --from=builder /.java /.java | |
COPY --from=builder /root/.java /root/.java | |
RUN chown -R mendix:mendix /build /buildpack /.java /root | |
WORKDIR /build | |
USER 1050 | |
# Expose nginx port | |
ENV PORT 8080 | |
EXPOSE $PORT | |
ENTRYPOINT ["/build/startup","/buildpack/start.py"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment