Skip to content

Commit

Permalink
Update Dockerfiles to set default TARGETPLATFORM and simplify multi-a…
Browse files Browse the repository at this point in the history
…rch support
  • Loading branch information
eduardolat committed Nov 2, 2024
1 parent 14b50fc commit cf83ac2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
15 changes: 8 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Declare the target platform to support multi-arch builds
ARG TARGETPLATFORM
ARG TARGETPLATFORM=linux/amd64

# To make sure we have the node, and golang binaries
FROM --platform=$TARGETPLATFORM node:20.17.0-bookworm AS node
FROM --platform=$TARGETPLATFORM golang:1.23.1-bookworm AS golang
FROM node:20.17.0-bookworm AS node
FROM golang:1.23.1-bookworm AS golang

# Set the base image, general environment variables, and move to temp dir
FROM --platform=$TARGETPLATFORM debian:12.7
RUN echo "Building for $TARGETPLATFORM"
FROM debian:12.7
ARG TARGETPLATFORM
RUN echo "Building for ${TARGETPLATFORM}"
ENV DEBIAN_FRONTEND="noninteractive"
ENV GOBIN="/usr/local/go-bin"
ENV PATH="$PATH:/usr/local/go-bin:/usr/local/dl-bin:/usr/local/go/bin"
Expand Down Expand Up @@ -37,7 +38,7 @@ RUN apt update && apt install -y postgresql-common && \
# Install downloadable binaries
RUN set -e && \
if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
echo "Downloading arm64 binaries" \
echo "Downloading arm64 binaries" && \
# Install task
wget --no-verbose https://github.com/go-task/task/releases/download/v3.38.0/task_linux_arm64.tar.gz && \
tar -xzf task_linux_arm64.tar.gz && \
Expand All @@ -54,7 +55,7 @@ RUN set -e && \
tar -xzf golangci-lint-1.60.3-linux-arm64.tar.gz && \
mv ./golangci-lint-1.60.3-linux-arm64/golangci-lint /usr/local/dl-bin/golangci-lint; \
else \
echo "Downloading amd64 binaries" \
echo "Downloading amd64 binaries" && \
# Install task
wget --no-verbose https://github.com/go-task/task/releases/download/v3.38.0/task_linux_amd64.tar.gz && \
tar -xzf task_linux_amd64.tar.gz && \
Expand Down
15 changes: 8 additions & 7 deletions docker/Dockerfile.cicd
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Declare the target platform to support multi-arch builds
ARG TARGETPLATFORM
ARG TARGETPLATFORM=linux/amd64

# To make sure we have the node, and golang binaries
FROM --platform=$TARGETPLATFORM node:20.17.0-bookworm AS node
FROM --platform=$TARGETPLATFORM golang:1.23.1-bookworm AS golang
FROM node:20.17.0-bookworm AS node
FROM golang:1.23.1-bookworm AS golang

# Set the base image, general environment variables, and move to temp dir
FROM --platform=$TARGETPLATFORM debian:12.7
RUN echo "Building for $TARGETPLATFORM"
FROM debian:12.7
ARG TARGETPLATFORM
RUN echo "Building for ${TARGETPLATFORM}"
ENV DEBIAN_FRONTEND="noninteractive"
ENV GOBIN="/usr/local/go-bin"
ENV PATH="$PATH:/usr/local/go-bin:/usr/local/dl-bin:/usr/local/go/bin"
Expand Down Expand Up @@ -37,7 +38,7 @@ RUN apt update && apt install -y postgresql-common && \
# Install downloadable binaries
RUN set -e && \
if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
echo "Downloading arm64 binaries" \
echo "Downloading arm64 binaries" && \
# Install task
wget --no-verbose https://github.com/go-task/task/releases/download/v3.38.0/task_linux_arm64.tar.gz && \
tar -xzf task_linux_arm64.tar.gz && \
Expand All @@ -54,7 +55,7 @@ RUN set -e && \
tar -xzf golangci-lint-1.60.3-linux-arm64.tar.gz && \
mv ./golangci-lint-1.60.3-linux-arm64/golangci-lint /usr/local/dl-bin/golangci-lint; \
else \
echo "Downloading amd64 binaries" \
echo "Downloading amd64 binaries" && \
# Install task
wget --no-verbose https://github.com/go-task/task/releases/download/v3.38.0/task_linux_amd64.tar.gz && \
tar -xzf task_linux_amd64.tar.gz && \
Expand Down
15 changes: 8 additions & 7 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Declare the target platform to support multi-arch builds
ARG TARGETPLATFORM
ARG TARGETPLATFORM=linux/amd64

# To make sure we have the node, and golang binaries
FROM --platform=$TARGETPLATFORM node:20.17.0-bookworm AS node
FROM --platform=$TARGETPLATFORM golang:1.23.1-bookworm AS golang
FROM node:20.17.0-bookworm AS node
FROM golang:1.23.1-bookworm AS golang

# Set the base image, general environment variables, and move to temp dir
FROM --platform=$TARGETPLATFORM debian:12.7
RUN echo "Building for $TARGETPLATFORM"
FROM debian:12.7
ARG TARGETPLATFORM
RUN echo "Building for ${TARGETPLATFORM}"
ENV DEBIAN_FRONTEND="noninteractive"
ENV GOBIN="/usr/local/go-bin"
ENV PATH="$PATH:/usr/local/go-bin:/usr/local/dl-bin:/usr/local/go/bin"
Expand Down Expand Up @@ -37,7 +38,7 @@ RUN apt update && apt install -y postgresql-common && \
# Install downloadable binaries
RUN set -e && \
if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
echo "Downloading arm64 binaries" \
echo "Downloading arm64 binaries" && \
# Install task
wget --no-verbose https://github.com/go-task/task/releases/download/v3.38.0/task_linux_arm64.tar.gz && \
tar -xzf task_linux_arm64.tar.gz && \
Expand All @@ -54,7 +55,7 @@ RUN set -e && \
tar -xzf golangci-lint-1.60.3-linux-arm64.tar.gz && \
mv ./golangci-lint-1.60.3-linux-arm64/golangci-lint /usr/local/dl-bin/golangci-lint; \
else \
echo "Downloading amd64 binaries" \
echo "Downloading amd64 binaries" && \
# Install task
wget --no-verbose https://github.com/go-task/task/releases/download/v3.38.0/task_linux_amd64.tar.gz && \
tar -xzf task_linux_amd64.tar.gz && \
Expand Down

0 comments on commit cf83ac2

Please sign in to comment.