Skip to content

Commit fd36fcf

Browse files
committed
feat: add openssl
1 parent 4e0e859 commit fd36fcf

File tree

2 files changed

+154
-0
lines changed

2 files changed

+154
-0
lines changed

.github/workflows/openssl.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: openssl
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
force:
6+
description: 'force build, regardless if tag exists already'
7+
required: false
8+
default: 'false'
9+
schedule:
10+
- cron: "0 5 * * *"
11+
push:
12+
tags:
13+
- 'openssl'
14+
jobs:
15+
openssl:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: cron-update / get latest version
19+
run: |
20+
LATEST_VERSION=$(curl -s https://api.github.com/repos/openssl/openssl/releases/latest | jq -r '.tag_name' | sed 's/openssl-//')
21+
if [ "${LATEST_VERSION}" != "null" ]; then
22+
if curl -kILs --fail https://hub.docker.com/v2/repositories/11notes/distroless/tags/openssl-${LATEST_VERSION}; then
23+
if [ "${{ github.event.inputs.force }}" == "true" ]; then
24+
echo "WORKFLOW_AUTO_UPDATE=true" >> "${GITHUB_ENV}"
25+
echo "LATEST_VERSION=${LATEST_VERSION}" >> "${GITHUB_ENV}"
26+
else
27+
echo "tag ${LATEST_VERSION} exists already!"
28+
fi
29+
else
30+
echo "WORKFLOW_AUTO_UPDATE=true" >> "${GITHUB_ENV}"
31+
echo "LATEST_VERSION=${LATEST_VERSION}" >> "${GITHUB_ENV}"
32+
fi
33+
else
34+
echo "tag ${LATEST_VERSION} is null!"
35+
fi
36+
37+
- name: init / base64 nested json
38+
if: env.WORKFLOW_AUTO_UPDATE == 'true'
39+
uses: actions/github-script@62c3794a3eb6788d9a2a72b219504732c0c9a298
40+
with:
41+
script: |
42+
const { Buffer } = require('node:buffer');
43+
const etc = {
44+
dockerfile:"openssl.dockerfile",
45+
tag:"openssl",
46+
version:"${{ env.LATEST_VERSION }}",
47+
semver:{disable:{rolling: true}}
48+
};
49+
core.exportVariable('WORKFLOW_BASE64JSON', Buffer.from(JSON.stringify(etc)).toString('base64'));
50+
51+
- name: build docker image
52+
if: env.WORKFLOW_AUTO_UPDATE == 'true'
53+
uses: the-actions-org/workflow-dispatch@3133c5d135c7dbe4be4f9793872b6ef331b53bc7
54+
with:
55+
wait-for-completion: false
56+
workflow: docker.yml
57+
token: "${{ secrets.REPOSITORY_TOKEN }}"
58+
inputs: '{ "release":"false", "readme":"false", "run-name":"openssl", "etc":"${{ env.WORKFLOW_BASE64JSON }}" }'

openssl.dockerfile

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# ╔═════════════════════════════════════════════════════╗
2+
# ║ SETUP ║
3+
# ╚═════════════════════════════════════════════════════╝
4+
# GLOBAL
5+
ARG APP_UID=1000 \
6+
APP_GID=1000
7+
8+
# :: FOREIGN IMAGES
9+
FROM 11notes/util:bin AS util-bin
10+
11+
12+
# ╔═════════════════════════════════════════════════════╗
13+
# ║ BUILD ║
14+
# ╚═════════════════════════════════════════════════════╝
15+
# :: OPENSSL
16+
FROM alpine AS build
17+
COPY --from=util-bin / /
18+
ARG APP_VERSION \
19+
APP_ROOT \
20+
TARGETARCH \
21+
TARGETVARIANT
22+
23+
RUN set -ex; \
24+
apk --update --no-cache add \
25+
perl \
26+
g++ \
27+
make \
28+
linux-headers \
29+
git \
30+
cmake \
31+
build-base \
32+
samurai \
33+
python3 \
34+
py3-pkgconfig \
35+
pkgconfig;
36+
37+
RUN set -ex; \
38+
eleven github asset openssl/openssl openssl-${APP_VERSION} openssl-${APP_VERSION}.tar.gz;
39+
40+
RUN set -ex; \
41+
cd /openssl-${APP_VERSION}; \
42+
case "${TARGETARCH}${TARGETVARIANT}" in \
43+
"amd64"|"arm64") \
44+
./Configure \
45+
-static \
46+
--openssldir=/etc/ssl; \
47+
;; \
48+
\
49+
"armv7") \
50+
./Configure \
51+
linux-generic32 \
52+
-static \
53+
--openssldir=/etc/ssl; \
54+
;; \
55+
esac;
56+
57+
RUN set -ex; \
58+
cd /openssl-${APP_VERSION}; \
59+
make -s -j $(nproc) 2>&1 > /dev/null;
60+
61+
RUN set -ex; \
62+
eleven distroless /openssl-${APP_VERSION}/apps/openssl;
63+
64+
65+
# ╔═════════════════════════════════════════════════════╗
66+
# ║ IMAGE ║
67+
# ╚═════════════════════════════════════════════════════╝
68+
# :: HEADER
69+
FROM scratch
70+
71+
# :: default arguments
72+
ARG TARGETPLATFORM \
73+
TARGETOS \
74+
TARGETARCH \
75+
TARGETVARIANT \
76+
APP_IMAGE \
77+
APP_NAME \
78+
APP_VERSION \
79+
APP_ROOT \
80+
APP_UID \
81+
APP_GID \
82+
APP_NO_CACHE
83+
84+
# :: default environment
85+
ENV APP_IMAGE=${APP_IMAGE} \
86+
APP_NAME=${APP_NAME} \
87+
APP_VERSION=${APP_VERSION} \
88+
APP_ROOT=${APP_ROOT}
89+
90+
# :: multi-stage
91+
COPY --from=build ${APP_ROOT}/ /
92+
93+
# :: EXECUTE
94+
USER ${APP_UID}:${APP_GID}
95+
ENTRYPOINT ["/usr/local/bin/openssl"]
96+
CMD ["--version"]

0 commit comments

Comments
 (0)