Skip to content

Commit

Permalink
Use TARGETARCH and TARGETOS to fetch the correct Go binary for multi-…
Browse files Browse the repository at this point in the history
…arch builds.

Signed-off-by: Rafael Zago <[email protected]>
  • Loading branch information
rafaelvzago committed Dec 12, 2024
1 parent 56d8453 commit 0d9f51c
Showing 1 changed file with 38 additions and 29 deletions.
67 changes: 38 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
FROM alpine:latest

# Install base tools without tshark
# Install base tools
RUN apk update && apk add --no-cache \
bash \
curl \
wget \
tar \
traceroute \
openssl \
iperf3 \
busybox-extras \
nmap \
netcat-openbsd \
tcpdump \
mtr \
socat \
bind-tools \
iproute2 \
openssh-client \
python3 \
procps \
coreutils \
mongodb-tools \
postgresql15-client \
py3-flask

# Install Go 1.22.8 manually to /usr/local/go
bash \
curl \
wget \
tar \
traceroute \
openssl \
iperf3 \
busybox-extras \
nmap \
netcat-openbsd \
tcpdump \
mtr \
socat \
bind-tools \
iproute2 \
openssh-client \
python3 \
procps \
coreutils \
mongodb-tools \
postgresql15-client \
py3-flask

# Set up build arguments (provided by buildx)
ARG TARGETOS
ARG TARGETARCH

# Set Go version
ENV GO_VERSION=1.22.8
RUN wget https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz && \
tar -C /usr/local -xzf go$GO_VERSION.linux-amd64.tar.gz && \
rm go$GO_VERSION.linux-amd64.tar.gz
# Compose the correct URL for the architecture
ENV GO_URL=https://dl.google.com/go/go${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz

# Download and install Go based on target architecture
RUN wget -O go.tar.gz $GO_URL && \
tar -C /usr/local -xzf go.tar.gz && \
rm go.tar.gz

# Set Go path
ENV PATH="/usr/local/go/bin:${PATH}"
Expand All @@ -40,8 +48,9 @@ RUN go version
# Copy the Flask app
COPY app.py /app.py

# Expose port 5000 for the app.py
# Expose port 5000
EXPOSE 5000

# Run the Flask app
CMD ["python3", "/app.py"]

0 comments on commit 0d9f51c

Please sign in to comment.