Skip to content

Commit d338e4e

Browse files
committed
chore: create unregistry-dind image for testing
1 parent 6e151fe commit d338e4e

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Allow files and directories.
55
!cmd/
66
!internal/
7+
!scripts/
78
!go.*
89

910
# Ignore unnecessary files inside allowed directories.

Dockerfile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,25 @@ COPY . .
1212
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o unregistry ./cmd/unregistry
1313

1414

15+
# Unregistry in Docker-in-Docker image for e2e tests.
16+
FROM docker:28.2.2-dind AS unregistry-dind
17+
18+
ENV UNREGISTRY_CONTAINERD_SOCK="/run/docker/containerd/containerd.sock"
19+
20+
COPY scripts/dind-entrypoint.sh /usr/local/bin/entrypoint.sh
21+
COPY --from=builder /build/unregistry /usr/local/bin/
22+
23+
EXPOSE 5000
24+
ENTRYPOINT ["entrypoint.sh"]
25+
CMD ["unregistry"]
26+
1527
# Create a minimal image with the static binary built in the builder stage.
1628
FROM alpine:${ALPINE_VERSION}
1729

18-
# TODO: remove when migrated to containerd storage.
19-
RUN mkdir -p /var/lib/unregistry
20-
2130
COPY --from=builder /build/unregistry /usr/local/bin/
31+
32+
EXPOSE 5000
2233
# Run as root user by default to allow access to the containerd socket. This in unfortunate as running as non-root user
2334
# requires changing the containerd socket permissions which still can be manually done by advanced users.
2435
ENTRYPOINT ["unregistry"]
36+

scripts/dind-entrypoint.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
# Cleanup function to properly terminate background processes.
5+
cleanup() {
6+
echo "Terminating container processes..."
7+
8+
# Terminate the main process if it has been started.
9+
if [ -n "${MAIN_PID:-}" ]; then
10+
kill "$MAIN_PID" 2>/dev/null || true
11+
fi
12+
13+
# Terminate Docker daemon if PID file exists.
14+
if [ -f /run/docker.pid ]; then
15+
kill "$(cat /run/docker.pid)" 2>/dev/null || true
16+
fi
17+
18+
# Wait for processes to terminate.
19+
wait
20+
}
21+
trap cleanup INT TERM EXIT
22+
23+
if [ "${DOCKER_CONTAINERD_STORE:-true}" = "true" ]; then
24+
echo "Using containerd image store for Docker."
25+
mkdir -p /etc/docker
26+
echo '{"features": {"containerd-snapshotter": true}}' > /etc/docker/daemon.json
27+
else
28+
echo "Using the default Docker image store."
29+
fi
30+
31+
dind dockerd --host=tcp://0.0.0.0:2375 --tls=false &
32+
33+
# Execute the passed command and wait for it while maintaining signal handling.
34+
"$@" &
35+
MAIN_PID=$!
36+
wait $MAIN_PID

0 commit comments

Comments
 (0)