File tree Expand file tree Collapse file tree 3 files changed +52
-3
lines changed Expand file tree Collapse file tree 3 files changed +52
-3
lines changed Original file line number Diff line number Diff line change 4
4
# Allow files and directories.
5
5
! cmd /
6
6
! internal /
7
+ ! scripts /
7
8
! go. *
8
9
9
10
# Ignore unnecessary files inside allowed directories.
Original file line number Diff line number Diff line change @@ -12,13 +12,25 @@ COPY . .
12
12
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o unregistry ./cmd/unregistry
13
13
14
14
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
+
15
27
# Create a minimal image with the static binary built in the builder stage.
16
28
FROM alpine:${ALPINE_VERSION}
17
29
18
- # TODO: remove when migrated to containerd storage.
19
- RUN mkdir -p /var/lib/unregistry
20
-
21
30
COPY --from=builder /build/unregistry /usr/local/bin/
31
+
32
+ EXPOSE 5000
22
33
# Run as root user by default to allow access to the containerd socket. This in unfortunate as running as non-root user
23
34
# requires changing the containerd socket permissions which still can be manually done by advanced users.
24
35
ENTRYPOINT ["unregistry" ]
36
+
Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments