[#699] Add alpine builds

* [#699] Add Dockerfile for alpine

* [#699] Add pod tests

* [#699] Add alpine image build

* [#699] Build images on CI

* [#699] Add actions

* [#699] Amend actions to the new flow
This commit is contained in:
Rahuλ Dé 2021-01-03 14:18:34 +01:00 committed by GitHub
parent cbe1210e62
commit 7b1e9cbe62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 21 deletions

View file

@ -153,6 +153,8 @@ jobs:
resource_class: large
steps:
- checkout
- attach_workspace:
at: /tmp
- run:
name: "Pull Submodules"
command: |
@ -207,6 +209,10 @@ jobs:
name: Release
command: |
.circleci/script/release
- persist_to_workspace:
root: /tmp
paths:
- release
- save_cache:
paths:
- ~/.m2
@ -310,21 +316,12 @@ jobs:
- ~/.m2
key: v1-dependencies-{{ checksum "project.clj" }}
docker:
resource_class: large
docker:
- image: circleci/buildpack-deps:stretch
steps:
- checkout
- attach_workspace:
at: /tmp
- run:
name: Unzip binary to root
command: unzip /tmp/release/*.zip
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update
- setup_remote_docker:
version: 19.03.12
- run:
@ -354,3 +351,4 @@ workflows:
only: master
requires:
- linux
- linux-static

View file

@ -17,16 +17,24 @@ fi
if [ -z "$CIRCLE_PULL_REQUEST" ] && [ "$CIRCLE_BRANCH" = "master" ]; then
echo "Building Docker image $image_name:$image_tag"
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USER" --password-stdin
unzip "/tmp/release/babashka-${image_tag}-linux-amd64.zip"
docker build -t "$image_name" -f Dockerfile.ci .
docker tag "$image_name:$latest_tag" "$image_name:$image_tag"
rm -f bb
unzip "/tmp/release/babashka-${image_tag}-linux-static-amd64.zip"
docker build -t "$image_name:alpine" -f Dockerfile.alpine .
docker tag "$image_name:alpine" "$image_name:$image_tag-alpine"
# we only update latest when it's not a SNAPSHOT version
if [ "false" = "$snapshot" ]; then
echo "Pushing image $image_name:$latest_tag"
docker push "$image_name:$latest_tag"
echo "Pushing image $image_name:alpine"
docker push "$image_name:alpine"
fi
# we update the version tag, even if it's a SNAPSHOT version
echo "Pushing image $image_name:$image_tag"
docker push "$image_name:$image_tag"
docker push "$image_name:$image_tag-alpine"
else
echo "Not publishing Docker image"
fi

View file

@ -19,16 +19,24 @@ if [ -z "$GITHUB_HEAD_REF" ] && [ "${GITHUB_REF##*/}" = "master" ]
then
echo "Building Docker image $image_name:$image_tag"
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USER" --password-stdin
unzip "/tmp/release/babashka-${image_tag}-linux-amd64.zip"
docker build -t "$image_name" -f Dockerfile.ci .
docker tag "$image_name:$latest_tag" "$image_name:$image_tag"
rm -f bb
unzip "/tmp/release/babashka-${image_tag}-linux-static-amd64.zip"
docker build -t "$image_name:alpine" -f Dockerfile.alpine .
docker tag "$image_name:alpine" "$image_name:$image_tag-alpine"
# we only update latest when it's not a SNAPSHOT version
if [ "false" = "$snapshot" ]; then
echo "Pushing image $image_name:$latest_tag"
docker push "$image_name:$latest_tag"
echo "Pushing image $image_name:alpine"
docker push "$image_name:alpine"
fi
# we update the version tag, even if it's a SNAPSHOT version
echo "Pushing image $image_name:$image_tag"
docker push "$image_name:$image_tag"
docker push "$image_name:$image_tag-alpine"
else
echo "Not publishing Docker image"
fi

View file

@ -165,13 +165,6 @@ jobs:
export GRAALVM_HOME="$HOME/graalvm-ce-java11-20.3.0"
BABASHKA_TEST_ENV=native script/test
- name: Save binary
uses: actions/upload-artifact@v2
with:
name: bb-linux-binary
path: |
bb
- name: Install clojure
run: |
sudo script/install-clojure /usr/local
@ -181,7 +174,8 @@ jobs:
export GRAALVM_HOME="$HOME/graalvm-ce-java11-20.3.0"
BABASHKA_TEST_ENV=native script/run_lib_tests
- uses: actions/upload-artifact@v1
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
path: bb
name: babashka-${{ steps.babashka-version.outputs.version }}-linux-amd64.zip
@ -263,7 +257,8 @@ jobs:
export GRAALVM_HOME="$HOME/graalvm-ce-java11-20.3.0"
BABASHKA_TEST_ENV=native script/run_lib_tests
- uses: actions/upload-artifact@v1
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
path: bb
name: babashka-${{ steps.babashka-version.outputs.version }}-linux-static-amd64.zip
@ -366,7 +361,9 @@ jobs:
docker:
if: "!contains(github.event.head_commit.message, 'skip ci') && github.event_name == 'push' && github.ref == 'refs/heads/master'"
needs: [linux]
needs:
- linux
- linux-static
runs-on: ubuntu-18.04
steps:
- name: Git checkout
@ -375,11 +372,26 @@ jobs:
fetch-depth: 1
submodules: 'true'
- name: Babashka version
id: babashka-version
run: |
BABASHKA_VERSION=$(cat resources/BABASHKA_VERSION)
echo "##[set-output name=version;]${BABASHKA_VERSION}"
- name: Make release dir
run: mkdir -p /tmp/release
- name: Download linux binary
uses: actions/download-artifact@v2
with:
name: bb-linux-binary
path: bb
name: babashka-${{ steps.babashka-version.outputs.version }}-linux-amd64.zip
path: /tmp/release
- name: Download static linux binary
uses: actions/download-artifact@v2
with:
name: babashka-${{ steps.babashka-version.outputs.version }}-linux-static-amd64.zip
path: /tmp/release
- name: Docker build
env:

29
Dockerfile.alpine Normal file
View file

@ -0,0 +1,29 @@
FROM alpine:3 AS tester
COPY bb /bin/bb
RUN chmod +x /bin/bb
RUN apk --no-cache add curl ca-certificates tar && \
curl -Ls https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk > /tmp/glibc-2.28-r0.apk && \
apk add --allow-untrusted /tmp/glibc-2.28-r0.apk
RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
# TODO: Run actual native tests when they are ported
RUN bb -e "(curl/get \"https://httpstat.us/200\")" # cURL http test
RUN bb -e "(require '[org.httpkit.client :as http]) (when-let [error (:error @(http/get \"https://httpstat.us/200\"))] (throw error))" # JVM http test
RUN bb -e "(.length \"Hello, Babashka\")" # Java interop test
RUN bb -e "(require '[babashka.pods :as pods]) (pods/load-pod 'org.babashka/sqlite3 \"0.0.1\") (require '[pod.babashka.sqlite3 :as sqlite]) (sqlite/execute! \"/tmp/foo.db\" [\"SELECT 1 + 1\"])" # Pod test
FROM alpine:3
RUN apk --no-cache add curl ca-certificates tar && \
curl -Ls https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk > /tmp/glibc-2.28-r0.apk && \
apk add --allow-untrusted /tmp/glibc-2.28-r0.apk
RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
COPY --from=tester /bin/bb /bin/bb
CMD ["bb"]