refactor: simplify file ownership in the container by setting the process ownership during the build process

Rather than require a heavy chown operation across various paths, just chown the files already in the built image during the release process. This ensures we can skip not-only the chown process during the container start that herokuish injects, but also the one that Dokku runs which modifies mounted container paths as well during the pre-deploy.

Note that users will need to ensure any mounted volumes don't have permissions reset by other processes or containers won't be able to access them.
This commit is contained in:
Jose Diaz-Gonzalez committed 2024-03-12 22:27:39 -04:00
1 parent 0d6bde2eff
commit 68d05b230d
12 files changed
+20 -83

No files matched your search

+4 -1
View File
@@ -33,7 +33,10 @@ trigger-builder-herokuish-builder-release() {
DOCKER_BUILD_ARGS+=("--platform=linux/amd64")
fi
if ! suppress_output "$DOCKER_BIN" image build "${DOCKER_BUILD_ARGS[@]}" $DOKKU_GLOBAL_BUILD_ARGS -f "$PLUGIN_AVAILABLE_PATH/builder-herokuish/dockerfiles/builder-release.Dockerfile" --build-arg APP_IMAGE="$IMAGE" -t "$IMAGE" "$TMP_WORK_DIR"; then
DOKKU_APP_USER=$(config_get "$APP" DOKKU_APP_USER || true)
DOKKU_APP_USER=${DOKKU_APP_USER:="herokuishuser"}
if ! suppress_output "$DOCKER_BIN" image build "${DOCKER_BUILD_ARGS[@]}" $DOKKU_GLOBAL_BUILD_ARGS -f "$PLUGIN_AVAILABLE_PATH/builder-herokuish/dockerfiles/builder-release.Dockerfile" --build-arg APP_IMAGE="$IMAGE" --build-arg DOKKU_APP_USER=$DOKKU_APP_USER -t "$IMAGE" "$TMP_WORK_DIR"; then
dokku_log_warn "Failure injecting environment variables"
return 1
fi
@@ -1,4 +1,7 @@
ARG APP_IMAGE
FROM $APP_IMAGE
COPY 00-global-env.sh 01-app-env.sh /app/.profile.d/
ARG DOKKU_APP_USER herokuishuser
COPY --chown=$DOKKU_APP_USER 00-global-env.sh 01-app-env.sh /app/.profile.d/
RUN chown -R $DOKKU_APP_USER:$DOKKU_APP_USER /app
USER $DOKKU_APP_USER
@@ -4,4 +4,5 @@ FROM $APP_IMAGE
ARG DOKKU_APP_USER herokuishuser
RUN USER=$DOKKU_APP_USER /exec true
COPY --chown=$DOKKU_APP_USER . /app
WORKDIR /app
WORKDIR /app
ENV HEROKUISH_DISABLE_CHOWN true
@@ -1,5 +1,5 @@
ARG APP_IMAGE
FROM $APP_IMAGE
COPY .env.d /tmp/env
COPY .env /app/.env
COPY --chown=$DOKKU_APP_USER .env.d /tmp/env
COPY --chown=$DOKKU_APP_USER .env /app/.env