Skip to content

Set DOCKER_GEN_VERSION in Docker image env #409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
build-args: VERSION=${{ env.GIT_DESCRIBE }}
build-args: DOCKER_GEN_VERSION=${{ env.GIT_DESCRIBE }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.docker_meta_alpine.outputs.tags }}
Expand All @@ -106,7 +106,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
build-args: VERSION=${{ env.GIT_DESCRIBE }}
build-args: DOCKER_GEN_VERSION=${{ env.GIT_DESCRIBE }}
file: Dockerfile.debian
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
Expand Down
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
ARG DOCKER_GEN_VERSION=main

# Build docker-gen from scratch
FROM golang:1.17.8-alpine as go-builder

ARG VERSION=main

ARG DOCKER_GEN_VERSION
WORKDIR /build

# Install the dependencies
COPY . .
RUN go mod download

# Build the docker-gen executable
RUN GOOS=linux CGO_ENABLED=0 go build -ldflags "-X main.buildVersion=${VERSION}" -o docker-gen ./cmd/docker-gen
RUN GOOS=linux CGO_ENABLED=0 go build -ldflags "-X main.buildVersion=${DOCKER_GEN_VERSION}" -o docker-gen ./cmd/docker-gen

FROM alpine:3.15.0

ENV DOCKER_HOST unix:///tmp/docker.sock
ARG DOCKER_GEN_VERSION
ENV DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION} \
DOCKER_HOST=unix:///tmp/docker.sock

# Install packages required by the image
RUN apk add --no-cache --virtual .bin-deps openssl
Expand Down
10 changes: 7 additions & 3 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
ARG DOCKER_GEN_VERSION=main

# Build docker-gen from scratch
FROM golang:1.17.8 as go-builder

ARG VERSION=main
ARG DOCKER_GEN_VERSION

WORKDIR /build

Expand All @@ -10,11 +12,13 @@ COPY . .
RUN go mod download

# Build the docker-gen executable
RUN GOOS=linux go build -ldflags "-X main.buildVersion=${VERSION}" -o docker-gen ./cmd/docker-gen
RUN GOOS=linux go build -ldflags "-X main.buildVersion=${DOCKER_GEN_VERSION}" -o docker-gen ./cmd/docker-gen

FROM debian:11.2-slim

ENV DOCKER_HOST unix:///tmp/docker.sock
ARG VERSION
ENV DOCKER_GEN_VERSION=${VERSION} \
DOCKER_HOST=unix:///tmp/docker.sock

# Install packages required by the image
RUN apt-get update \
Expand Down