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

feat: do multi stage build #54

Merged
merged 1 commit into from
Sep 27, 2024
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
3 changes: 3 additions & 0 deletions .github/workflows/build_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
RUBYGEM_MODULESYNC=${{ matrix.rubygem_modulesync }}
RUBYGEM_RUBOCOP_PERFORMANCE=${{ matrix.rubygem_rubocop_performance }}
RUBYGEM_BUNDLER=${{ matrix.rubygem_bundler }}
APK_JQ=${{ matrix.apk_jq }}
APK_YAMLLINT=${{ matrix.apk_yamllint }}
APK_GIT=${{ matrix.apk_git }}
build_arch: linux/amd64,linux/arm64
docker_username: voxpupulibot
docker_password: ${{ secrets.DOCKERHUB_BOT_PASSWORD }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:
RUBYGEM_OVERCOMMIT=${{ matrix.rubygem_overcommit }}
RUBYGEM_MODULESYNC=${{ matrix.rubygem_modulesync }}
RUBYGEM_BUNDLER=${{ matrix.rubygem_bundler }}
APK_JQ=${{ matrix.apk_jq }}
APK_YAMLLINT=${{ matrix.apk_yamllint }}
APK_GIT=${{ matrix.apk_git }}

- name: Clone voxpupuli/puppet-example repository
uses: actions/checkout@v4
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/security_scanning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ jobs:
RUBYGEM_OVERCOMMIT=${{ matrix.rubygem_overcommit }}
RUBYGEM_MODULESYNC=${{ matrix.rubygem_modulesync }}
RUBYGEM_BUNDLER=${{ matrix.rubygem_bundler }}
APK_JQ=${{ matrix.apk_jq }}
APK_YAMLLINT=${{ matrix.apk_yamllint }}
APK_GIT=${{ matrix.apk_git }}

- name: Scan image with Anchore Grype
uses: anchore/scan-action@v4
Expand Down
45 changes: 30 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
ARG BASE_IMAGE=docker.io/ruby:3.2.5-alpine3.20

FROM $BASE_IMAGE

LABEL org.label-schema.maintainer="Voxpupuli Team <[email protected]>" \
org.label-schema.vendor="Voxpupuli" \
org.label-schema.url="https://github.com/voxpupuli/container-voxbox" \
org.label-schema.name="Vox Pupuli Test Box" \
org.label-schema.license="AGPL-3.0-or-later" \
org.label-schema.vcs-url="https://github.com/voxpupuli/container-voxbox" \
org.label-schema.schema-version="1.0" \
org.label-schema.dockerfile="/Dockerfile"
FROM $BASE_IMAGE AS builder

ARG RUBYGEM_PUPPET
ENV RUBYGEM_PUPPET=${RUBYGEM_PUPPET:-8.8.1}
ENV RUBYGEM_PUPPET ${RUBYGEM_PUPPET:-8.8.1}

ARG RUBYGEM_FACTER
ENV RUBYGEM_FACTER=${RUBYGEM_FACTER:-4.8.0}
Expand Down Expand Up @@ -45,14 +36,10 @@ ARG RUBYGEM_BUNDLER
ENV RUBYGEM_BUNDLER=${RUBYGEM_BUNDLER:-2.5.18}

COPY voxbox/Gemfile /
COPY voxbox/Rakefile /
COPY Dockerfile /

RUN apk update \
&& apk upgrade \
&& apk add --no-cache --update alpine-sdk \
&& apk add --no-cache --update yamllint \
&& apk add --no-cache --update jq \
&& rm -rf /usr/local/lib/ruby/gems/*/gems/bundler-* \
&& rm -rf /usr/local/lib/ruby/gems/*/specifications/default/bundler-*.gemspec \
&& gem install bundler -v ${RUBYGEM_BUNDLER} \
Expand All @@ -71,6 +58,34 @@ RUN apk update \
&& rm -rf /usr/local/lib/ruby/gems/*/gems/rexml-* \
&& rm -rf /usr/local/lib/ruby/gems/*/specifications/rexml-*.gemspec

###############################################################################

FROM $BASE_IMAGE AS final

LABEL org.label-schema.maintainer="Voxpupuli Team <[email protected]>" \
org.label-schema.vendor="Voxpupuli" \
org.label-schema.url="https://github.com/voxpupuli/container-voxbox" \
org.label-schema.name="Vox Pupuli Test Box" \
org.label-schema.license="AGPL-3.0-or-later" \
org.label-schema.vcs-url="https://github.com/voxpupuli/container-voxbox" \
org.label-schema.schema-version="1.0" \
org.label-schema.dockerfile="/Dockerfile"

ARG APK_JQ=1.7.1-r0
ARG APK_YAMLLINT=1.35.1-r1
ARG APK_GIT=2.45.2-r0

RUN apk update \
&& apk upgrade \
&& apk add jq=${APK_JQ} \
&& apk add yamllint=${APK_YAMLLINT} \
&& apk add git=${APK_GIT} \
&& rm -rf /var/cache/apk/*

COPY --from=builder /usr/local/bundle /usr/local/bundle
COPY Dockerfile /
COPY voxbox/Rakefile /

WORKDIR /repo

ENTRYPOINT [ "rake" ]
Expand Down
10 changes: 8 additions & 2 deletions build_versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"rubygem_r10k": "4.1.0",
"rubygem_ra10ke": "3.1.0",
"rubygem_rubocop_performance": "1.21.1",
"rubygem_bundler": "2.4.22"
"rubygem_bundler": "2.4.22",
"apk_jq": "1.6-r1",
"apk_yamllint": "1.26.3-r1",
"apk_git": "2.36.6-r0"
},
{
"puppet_release": 8,
Expand All @@ -30,7 +33,10 @@
"rubygem_r10k": "4.1.0",
"rubygem_ra10ke": "3.1.0",
"rubygem_rubocop_performance": "1.21.1",
"rubygem_bundler": "2.5.18"
"rubygem_bundler": "2.5.18",
"apk_jq": "1.7.1-r0",
"apk_yamllint": "1.35.1-r1",
"apk_git": "2.45.2-r0"
}
]
}
Loading