diff --git a/.circleci/config.yml b/.circleci/config.yml index 85c2f024..4e45fab3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/.circleci/script/docker b/.circleci/script/docker index e361b576..2f2b90b4 100755 --- a/.circleci/script/docker +++ b/.circleci/script/docker @@ -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 diff --git a/.github/script/docker b/.github/script/docker index 55552deb..657c2a37 100755 --- a/.github/script/docker +++ b/.github/script/docker @@ -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 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7950a76b..f234b818 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 00000000..63cf4561 --- /dev/null +++ b/Dockerfile.alpine @@ -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"]