Skip to content

Commit

Permalink
Simplify image building (#11)
Browse files Browse the repository at this point in the history
* Build process using scratch image
  • Loading branch information
greg-agacinski authored Apr 3, 2023
1 parent 08a1361 commit 7939be4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 26 deletions.
25 changes: 8 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
FROM --platform=linux/x86_64 alpine:latest
ENV GLIBC_REPO=https://github.com/sgerrand/alpine-pkg-glibc
ENV GLIBC_VERSION=2.35-r0
RUN set -ex && \
apk --update add libstdc++ curl ca-certificates && \
for pkg in glibc-${GLIBC_VERSION} glibc-bin-${GLIBC_VERSION}; \
do curl -sSL ${GLIBC_REPO}/releases/download/${GLIBC_VERSION}/${pkg}.apk -o /tmp/${pkg}.apk; done && \
apk add --force-overwrite --allow-untrusted /tmp/*.apk && \
rm -v /tmp/*.apk && \
/usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib
RUN apk add git
COPY ./sloctl-linux-* /usr/local/bin/sloctl
RUN chmod +x /usr/local/bin/sloctl
RUN adduser -D appuser
RUN mkdir -p /home/appuser/.config/nobl9
RUN chown -R appuser:appuser /home/appuser/.config/nobl9
USER appuser
FROM curlimages/curl:latest AS builder
ARG VERSION
RUN curl -sL https://github.com/nobl9/sloctl/releases/download/$VERSION/sloctl-linux-${VERSION/v/} -o /tmp/sloctl
RUN chmod +x /tmp/sloctl

FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /tmp/sloctl /usr/bin/
ENTRYPOINT ["sloctl"]
17 changes: 8 additions & 9 deletions codefresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ steps:
git: "github"
stage: "clone"

install:
title: "Install sloctl"
type: "freestyle" # Run any command
image: "ubuntu:latest" # The image in which command will be executed
working_directory: "${{clone}}" # Running command where code cloned
version:
title: "Get sloctl version"
type: "freestyle"
image: 'alpine:3.17.2'
commands:
- "apt-get update"
- "apt-get install -y wget git curl jq"
- curl -s https://api.github.com/repos/nobl9/sloctl/releases/latest | jq -r '.assets[] | select(.name | startswith("sloctl-linux-")) | .browser_download_url' | wget -qi -
- 'cf_export VERSION=$(curl -s https://api.github.com/repos/nobl9/sloctl/releases/latest | jq -r ".tag_name")'
- apk add wget jq
- cf_export VERSION=$(wget -qO- https://api.github.com/repos/nobl9/sloctl/releases/latest | jq -r '.tag_name')
stage: "build"

build:
Expand All @@ -36,6 +33,8 @@ steps:
dockerfile: 'Dockerfile'
registry: "nobl9"
tag: "${{VERSION}}"
build_arguments:
- VERSION=${{VERSION}}
tags:
- "latest"
stage: "build"

0 comments on commit 7939be4

Please sign in to comment.