Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace COPY with bind mount in modules examples #857

Merged
merged 4 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .test/tests/modules/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fi

# Create an instance of the container-under-test
modulesImage="$("$HOME/oi/test/tests/image-name.sh" librarytest/nginx-template "$image")"
DOCKER_BUILDKIT=0 docker build --build-arg NGINX_FROM_IMAGE="$image" --build-arg ENABLED_MODULES="ndk set-misc echo" -t "$modulesImage" -f "modules/$dockerfile" "$GITHUB_WORKSPACE/modules"
docker build --build-arg NGINX_FROM_IMAGE="$image" --build-arg ENABLED_MODULES="ndk set-misc echo" -t "$modulesImage" -f "modules/$dockerfile" "$GITHUB_WORKSPACE/modules"

serverImage="${modulesImage}-sme"
"$HOME/oi/test/tests/docker-build.sh" "$dir" "$serverImage" <<EOD
Expand Down
5 changes: 2 additions & 3 deletions modules/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,11 @@ RUN set -ex \
&& echo "BUILT_MODULES=\"$BUILT_MODULES\"" > /tmp/packages/modules.env

FROM ${NGINX_FROM_IMAGE}
COPY --from=builder /tmp/packages /tmp/packages
RUN set -ex \
RUN --mount=type=bind,target=/tmp/packages/,source=/tmp/packages/,from=builder \
set -ex \
&& apt update \
&& . /tmp/packages/modules.env \
&& for module in $BUILT_MODULES; do \
apt install --no-install-suggests --no-install-recommends -y /tmp/packages/nginx-module-${module}_${NGINX_VERSION}*.deb; \
done \
&& rm -rf /tmp/packages \
&& rm -rf /var/lib/apt/lists/
7 changes: 3 additions & 4 deletions modules/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ RUN set -ex \
&& echo "BUILT_MODULES=\"$BUILT_MODULES\"" > /tmp/packages/modules.env

FROM ${NGINX_FROM_IMAGE}
COPY --from=builder /tmp/packages /tmp/packages
RUN set -ex \
RUN --mount=type=bind,target=/tmp/packages/,source=/tmp/packages/,from=builder \
set -ex \
&& . /tmp/packages/modules.env \
&& for module in $BUILT_MODULES; do \
apk add --no-cache --allow-untrusted /tmp/packages/nginx-module-${module}-${NGINX_VERSION}*.apk; \
done \
&& rm -rf /tmp/packages
done
11 changes: 11 additions & 0 deletions modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ your own instuctions following a simple filesystem layout/syntax using
`build_module.sh` helper script, or falling back to package sources from
[pkg-oss](https://hg.nginx.org/pkg-oss).

## Requirements

To use the Dockerfiles provided here,
[Docker BuildKit](https://docs.docker.com/build/buildkit/) is required.
This is enabled by default as of version 23.0; for earlier versions this can be
enabled by setting the environment variable `DOCKER_BUILDKIT` to `1`.

If you can not or do not want to use BuildKit, you can use a previous version
of these files, see for example
https://github.com/nginxinc/docker-nginx/tree/4bf0763f4977fff7e9648add59e0540088f3ca9f/modules.

## Usage

```
Expand Down