Skip to content
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

chore(Dockerfile): Refactor dockerfile to Debian Slim with no deps #613

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
66 changes: 58 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,47 @@ variables:
S3_BUCKET_NAME: "mender"
S3_BUCKET_PATH: "mender-artifact"
DOCKER_BUILDKIT: 1
DOCKER_PLATFORMS:
value: "linux/amd64,linux/arm64"
description: "Platforms for building and distributing container images"

test:check-license-source:
variables:
LICENSE_HEADERS_IGNORE_FILES_REGEXP: './artifact/keyfactor/\(signer\|signer_test\)\.go'

build:docker:
image: docker
image: docker:26-cli
needs: []
services:
- docker:dind
- docker:26-dind
stage: build
before_script:
- |
echo ${CI_REGISTRY_PASSWORD} | \
docker login \
--username "$CI_REGISTRY_USER" \
--password-stdin \
"$CI_REGISTRY"
- docker buildx create --platform "$DOCKER_PLATFORMS" --name builder --bootstrap --use
script:
- docker build -t $DOCKER_REPOSITORY:pr .
- docker save $DOCKER_REPOSITORY:pr > image.tar
artifacts:
expire_in: 2w
paths:
- image.tar
- |
docker buildx build --push \
--platform "$DOCKER_PLATFORMS" \
--tag "$CI_REGISTRY_IMAGE:$CI_PIPELINE_IID" \
.
tags:
- gitlab-org-docker

build:yoctocompat:
# Keep golang version aligned with latest yocto release
image: golang:1.17.13-bullseye
alfrunes marked this conversation as resolved.
Show resolved Hide resolved
needs: []
before_script:
- apt-get update
- apt-get install -qy libssl-dev
script:
- go build

build:make:
image: docker
needs: []
Expand Down Expand Up @@ -260,6 +280,36 @@ publish:s3:
only:
- /^(master|[0-9]+\.[0-9]+\.x)$/

publish:docker:
stage: publish
rules:
- if: '$CI_COMMIT_TAG'
- if: '$CI_COMMIT_BRANCH == "master"'
- when: manual # Fallback; allow manual trigger
allow_failure: true
image:
name: "quay.io/skopeo/stable:v1.15"
# https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#override-the-entrypoint-of-an-image
entrypoint: [""]
before_script:
- |
echo ${CI_REGISTRY_PASSWORD} | \
skopeo login \
--username "$CI_REGISTRY_USER" \
--password-stdin \
"$CI_REGISTRY"
- |
echo ${DOCKER_HUB_PASSWORD} | \
skopeo login \
--username "$DOCKER_HUB_USERNAME" \
--password-stdin \
docker.io
script:
- |
skopeo copy --multi-arch all \
"docker://${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}" \
"docker://docker.io/mendersoftware/mender-artifact:${CI_COMMIT_REF_NAME}"

generate-qa-trigger:
image: python:alpine
stage: trigger_prep
Expand Down
19 changes: 10 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Keep golang version aligned with latest yocto release
FROM golang:1.17.13-bullseye as builder
RUN mkdir -p /go/src/github.com/mendersoftware/mender-artifact
WORKDIR /go/src/github.com/mendersoftware/mender-artifact
ADD ./ .
RUN make get-build-deps && \
make build && \
make install
ENTRYPOINT [ "/go/bin/mender-artifact" ]
FROM golang:1.22.4 as builder-deb
WORKDIR /build
COPY . .
RUN apt update && apt install -qy libssl-dev && \
make build

FROM debian:12.5-slim
COPY --from=builder-deb /build/mender-artifact /usr/bin/mender-artifact
RUN apt update && apt install -qy openssl
ENTRYPOINT ["/usr/bin/mender-artifact"]