# Build a project image running supervisor on startup and autostarting all daemons # Building requires a more recent docker version than v1.13.1 so don't build from a Centos 7.9 machine # Pull in CHART framework ARG CHART_FRAMEWORK_IMAGE_NAME FROM ${CHART_FRAMEWORK_IMAGE_NAME} WORKDIR /app # Copy application files ARG CHART_REPO_NAME ENV CHART_REPO_NAME="${CHART_REPO_NAME}" COPY . ${CHART_REPO_NAME}/ # Create the consolidated static directory ARG CHART_LAUNCHER_NAME ENV CHART_LAUNCHER_NAME="${CHART_LAUNCHER_NAME}" RUN CHART_STATIC_ROOT=/mnt/static ${CHART_REPO_NAME}/bin/${CHART_LAUNCHER_NAME} django_manage collectstatic --no-input # The startup file template is expanded now so it's available on container startup ARG CHART_PROJECT_NAME ENV CHART_PROJECT_NAME="${CHART_PROJECT_NAME}" # Copy the container startup script to /app to make it more visible and # Expand .bashrc as we have everything needed and # Symlink /app/scripts to the actual scripts directory for better visibility # Make log.config writeable by scripts/webserver.sh RUN chown -R root:root /app && \ cp ${CHART_REPO_NAME}/docker/project/startup.sh . && \ envsubst '$CHART_REPO_NAME' < ${CHART_REPO_NAME}/docker/project/bashrc.docker.tmpl > .bashrc && \ chmod +x .bashrc && \ ln -s ${CHART_REPO_NAME}/docker/project/scripts . && \ touch log.config && \ chmod 666 log.config # Fix permissions so the container can be started as a different user to the one who created the image # And make some directories used by the DEV runtime configuration settings RUN chmod 777 /app && \ chmod 777 /app/${CHART_REPO_NAME} && \ chmod 777 /app/${CHART_REPO_NAME}/${CHART_PROJECT_NAME} && \ mkdir /var/log/chart && \ mkdir /run/chart && \ mkdir /work # Make the reports SU writeable by the normal user. This is needed for the DU patch function only RUN chmod -R o+w /app/${CHART_REPO_NAME}/chartepssg_du # Create a default username and uid which is intended to be dynamically replaced at runtime # via custom passwd and groups files # ARG CHART_USERNAME=chart # ARG CHART_UID=1001 # RUN useradd ${CHART_USERNAME} --uid ${CHART_UID} --home-dir /app --shell /bin/bash --no-log-init && \ # chown ${CHART_USERNAME} /app # USER ${CHART_USERNAME} # Write a VERSIONS file inside the image ARG PROJECT_VCS_BRANCH ARG PROJECT_VCS_TAG ARG PROJECT_VCS_COMMIT ARG PROJECT_BUILD_DIRTY ARG DU_VCS_BRANCH ARG DU_VCS_TAG ARG DU_VCS_COMMIT ARG DU_BUILD_DIRTY # ARG DU_SRDB_VCS_BRANCH # ARG DU_SRDB_VCS_TAG # ARG DU_SRDB_VCS_COMMIT # ARG DU_SRDB_BUILD_DIRTY ARG PROJECT_BUILD_USER ARG PROJECT_BUILD_HOST ARG PROJECT_BUILD_DIR RUN echo "project.vcs.branch=${PROJECT_VCS_BRANCH}\n\ project.vcs.tag=${PROJECT_VCS_TAG}\n\ project.vcs.commit=${PROJECT_VCS_COMMIT}\n\ project.build.dirty=${PROJECT_BUILD_DIRTY}\n\ du.vcs.branch=${DU_VCS_BRANCH}\n\ du.vcs.tag=${DU_VCS_TAG}\n\ du.vcs.commit=${DU_VCS_COMMIT}\n\ du.build.dirty=${DU_BUILD_DIRTY}\n\ # du_srdb.vcs.branch=${DU_SRDB_VCS_BRANCH}\n\ # du_srdb.vcs.tag=${DU_SRDB_VCS_TAG}\n\ # du_srdb.vcs.commit=${DU_SRDB_VCS_COMMIT}\n\ # du_srdb.build.dirty=${DU_SRDB_BUILD_DIRTY}\n\ project.build.user=${PROJECT_BUILD_USER}\n\ project.build.host=${PROJECT_BUILD_HOST}\n\ project.build.dir=${PROJECT_BUILD_DIR}"\ > ${CHART_REPO_NAME}/VERSIONS # Set image labels LABEL "eum.chart.project.vcs.branch"="${PROJECT_VCS_BRANCH}" LABEL "eum.chart.project.vcs.tag"="${PROJECT_VCS_TAG}" LABEL "eum.chart.project.vcs.commit"="${PROJECT_VCS_COMMIT}" LABEL "eum.chart.project.build.dirty"="${PROJECT_BUILD_DIRTY}" LABEL "eum.chart.du.vcs.branch"="${DU_VCS_BRANCH}" LABEL "eum.chart.du.vcs.tag"="${DU_VCS_TAG}" LABEL "eum.chart.du.vcs.commit"="${DU_VCS_COMMIT}" LABEL "eum.chart.du.build.dirty"="${DU_BUILD_DIRTY}" # LABEL "eum.chart.du.srdb.vcs.branch"="${DU_SRDB_VCS_BRANCH}" # LABEL "eum.chart.du.srdb.vcs.tag"="${DU_SRDB_VCS_TAG}" # LABEL "eum.chart.du.srdb.vcs.commit"="${DU_SRDB_VCS_COMMIT}" # LABEL "eum.chart.du.srdb.build.dirty"="${DU_SRDB_BUILD_DIRTY}" LABEL "eum.chart.project.build.user"="${PROJECT_BUILD_USER}" LABEL "eum.chart.project.build.host"="${PROJECT_BUILD_HOST}" LABEL "eum.chart.project.build.dir"="${PROJECT_BUILD_DIR}" # On startup run our special creator file that expands runtime template variables ENTRYPOINT [ "./startup.sh" ] # By default launch supervisor on startup CMD ["bash"]