@@ -4,7 +4,13 @@ FROM ubuntu:22.04
4
4
ARG GRAYLOG_VERSION
5
5
ARG VCS_REF
6
6
ARG BUILD_DATE
7
- ARG LOCAL_BUILD_TGZ
7
+ # The LOCAL_BUILD_TGZ variable defaults to an empty file. If the variable is
8
+ # empty, Docker copies the full context dir into the container. It basically
9
+ # executes the following:
10
+ # COPY "" "/tmp/datanode-local.tar.gz"
11
+ # That creates a /tmp/datanode-local.tar.gz in the container with all files
12
+ # from the build context.
13
+ ARG LOCAL_BUILD_TGZ=.empty
8
14
ARG SNAPSHOT_URL_X64=https://downloads.graylog.org/releases/graylog-datanode/graylog-datanode-${GRAYLOG_VERSION}-linux-x64.tgz
9
15
ARG SNAPSHOT_URL_AARCH64=https://downloads.graylog.org/releases/graylog-datanode/graylog-datanode-${GRAYLOG_VERSION}-linux-aarch64.tgz
10
16
ARG DEBIAN_FRONTEND=noninteractive
@@ -50,19 +56,24 @@ RUN apt-get update \
50
56
/var/log/*
51
57
52
58
RUN install -d -o root -g root -m 0755 "$GDN_APP_ROOT"
59
+
53
60
COPY "${LOCAL_BUILD_TGZ}" "/tmp/datanode-local.tar.gz"
54
- RUN if [ -f /tmp/datanode-local.tar.gz ]; then \
55
- mv /tmp/datanode-local.tar.gz /tmp/datanode.tar.gz \
56
- ; fi
57
- RUN if [ -z "${LOCAL_BUILD_TGZ}" ]; then \
61
+
62
+ # An empty /tmp/datanode-local.tar.gz file indicates that we don't use a
63
+ # custom LOCAL_BUILD_TGZ file.
64
+ RUN if [ -f /tmp/datanode-local.tar.gz ] && [ -s /tmp/datanode-local.tar.gz ]; then \
65
+ mv /tmp/datanode-local.tar.gz /tmp/datanode.tar.gz; \
66
+ fi; \
67
+ if [ "${LOCAL_BUILD_TGZ}" == ".empty" ]; then \
58
68
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
59
69
export SNAPSHOT_URL="$SNAPSHOT_URL_AARCH64" ; \
60
70
else \
61
71
export SNAPSHOT_URL="$SNAPSHOT_URL_X64" ; \
62
72
fi; \
63
- curl -fsSL --retry 3 "$SNAPSHOT_URL" -o /tmp/datanode.tar.gz \
64
- ; fi
65
- RUN tar -C "$GDN_APP_ROOT" --strip-components=1 -xzf /tmp/datanode.tar.gz \
73
+ curl -fsSL --retry 3 "$SNAPSHOT_URL" -o /tmp/datanode.tar.gz; \
74
+ fi; \
75
+ tar -C "$GDN_APP_ROOT" --strip-components=1 -xzf /tmp/datanode.tar.gz \
76
+ && rm -rf /tmp/datanode-local.tar.gz /tmp/datanode.tar.gz \
66
77
&& mv "$GDN_APP_ROOT/config/" * "$GDN_CONFIG_DIR" / \
67
78
&& rmdir "$GDN_APP_ROOT/config" \
68
79
&& chown -R "$GDN_USER" :"$GDN_GROUP" "$GDN_CONFIG_DIR" \
0 commit comments