Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
node version as build variable
Browse files Browse the repository at this point in the history
  • Loading branch information
oznu committed Oct 27, 2021
1 parent 2057ca8 commit 65fee3b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,24 @@ jobs:
docker run --rm --privileged multiarch/qemu-user-static:register --reset
# get branch / tag name
- name: Get Branch / Tag Name
id: get_branch
run: |
export RELEASE_NAME=$(if [[ ${GITHUB_REF} =~ "refs/tags/" ]]; then echo ${GITHUB_REF/refs\/tags\//}; else echo ${GITHUB_REF/refs\/heads\//}; fi)
echo $RELEASE_NAME
echo ::set-output name=NAME::${RELEASE_NAME}
- name: Get the upload URL for a release
id: get_release
uses: bruceadams/get-release@v1.2.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# generate the image tag
- name: Get Image Tag
id: get_tag
run: |
export TARGET_IMAGE_TAG=$(if [ "${{ steps.get_branch.outputs.NAME }}" = "master" ]; then if [ "${{ matrix.TAG_SUFFIX }}" = "" ]; then echo "latest"; else echo "${{ matrix.TAG_SUFFIX }}"; fi; else if [ "${{ matrix.TAG_SUFFIX }}" = "" ]; then echo "${{ steps.get_branch.outputs.NAME }}"; else echo "${{ steps.get_branch.outputs.NAME }}-${{ matrix.TAG_SUFFIX }}"; fi; fi)
export TARGET_IMAGE_TAG=$(if [ "${{ steps.get_release.outputs.tag_name }}" = "master" ]; then if [ "${{ matrix.TAG_SUFFIX }}" = "" ]; then echo "latest"; else echo "${{ matrix.TAG_SUFFIX }}"; fi; else if [ "${{ matrix.TAG_SUFFIX }}" = "" ]; then echo "${{ steps.get_release.outputs.tag_name }}"; else echo "${{ steps.get_release.outputs.tag_name }}-${{ matrix.TAG_SUFFIX }}"; fi; fi)
echo $TARGET_IMAGE_TAG
echo ::set-output name=NAME::${TARGET_IMAGE_TAG}
# build the image
- name: Build Image
run: |
docker build -f ${{ matrix.DOCKERFILE }} --build-arg BASE_IMAGE=${{ matrix.BASE_IMAGE }} --build-arg QEMU_ARCH=${{ matrix.QEMU_ARCH }} -t ${{ matrix.TARGET_IMAGE }}:${{ steps.get_tag.outputs.NAME }} .
docker build -f ${{ matrix.DOCKERFILE }} --build-arg NODE_VERSION=${{ steps.get_release.outputs.tag_name }} --build-arg BASE_IMAGE=${{ matrix.BASE_IMAGE }} --build-arg QEMU_ARCH=${{ matrix.QEMU_ARCH }} -t ${{ matrix.TARGET_IMAGE }}:${{ steps.get_tag.outputs.NAME }} .
# push the image to docker hub
- name: Push Image
Expand All @@ -116,7 +115,7 @@ jobs:
echo "No alternate tags set for this build.";
else
echo "Tagging with alternate tag '${{ matrix.ALT_SUFFIX }}'";
export ALT_IMAGE_TAG=$(if [ "${{ steps.get_branch.outputs.NAME }}" = "master" ]; then if [ "${{ matrix.ALT_SUFFIX }}" = "" ]; then echo "error"; else echo "${{ matrix.ALT_SUFFIX }}"; fi; else if [ "${{ matrix.ALT_SUFFIX }}" = "" ]; then echo "${{ steps.get_branch.outputs.NAME }}"; else echo "${{ steps.get_branch.outputs.NAME }}-${{ matrix.ALT_SUFFIX }}"; fi; fi);
export ALT_IMAGE_TAG=$(if [ "${{ steps.get_release.outputs.tag_name }}" = "master" ]; then if [ "${{ matrix.ALT_SUFFIX }}" = "" ]; then echo "error"; else echo "${{ matrix.ALT_SUFFIX }}"; fi; else if [ "${{ matrix.ALT_SUFFIX }}" = "" ]; then echo "${{ steps.get_release.outputs.tag_name }}"; else echo "${{ steps.get_release.outputs.tag_name }}-${{ matrix.ALT_SUFFIX }}"; fi; fi);
docker tag ${{ matrix.TARGET_IMAGE }}:${{ steps.get_tag.outputs.NAME }} ${{ matrix.TARGET_IMAGE }}:$ALT_IMAGE_TAG;
docker push ${{ matrix.TARGET_IMAGE }}:$ALT_IMAGE_TAG;
fi
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ FROM ${BASE_IMAGE:-library/alpine}:3.12
ARG QEMU_ARCH
ENV QEMU_ARCH=${QEMU_ARCH:-x86_64} S6_KEEP_ENV=1

ARG NODE_VERSION
ENV NODE_VERSION=${NODE_VERSION:-14.18.1}

COPY qemu/qemu-${QEMU_ARCH}-static /usr/bin/

RUN set -x && apk add --no-cache libgcc libstdc++ curl curl-dev coreutils tzdata shadow libstdc++ paxmark logrotate py3-pip \
Expand All @@ -23,8 +26,6 @@ RUN set -x && apk add --no-cache libgcc libstdc++ curl curl-dev coreutils tzdata
&& rm -rf /tmp/* \
&& sed -i "s#/var/log/messages {}.*# #g" /etc/logrotate.conf

ENV NODE_VERSION 14.18.1

RUN set -x && curl -fLO https://github.com/oznu/alpine-node/releases/download/${NODE_VERSION}/node-v${NODE_VERSION}-linux-${QEMU_ARCH}-alpine.tar.gz \
&& tar -xzf node-v${NODE_VERSION}-linux-${QEMU_ARCH}-alpine.tar.gz -C /usr --strip-components=1 --no-same-owner \
&& rm -rf node-v${NODE_VERSION}-linux-${QEMU_ARCH}-alpine.tar.gz \
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ FROM ${BASE_IMAGE:-library/ubuntu}:18.04
ARG QEMU_ARCH
ENV QEMU_ARCH=${QEMU_ARCH:-x86_64} S6_KEEP_ENV=1

ARG NODE_VERSION
ENV NODE_VERSION=${NODE_VERSION:-14.18.1}

COPY qemu/qemu-${QEMU_ARCH}-static /usr/bin/

RUN set -x && apt-get update \
Expand All @@ -29,7 +32,6 @@ RUN set -x && apt-get update \
&& rm -rf /etc/cron.daily/apt-compat /etc/cron.daily/dpkg /etc/cron.daily/passwd /etc/cron.daily/exim4-base \
&& sed -i "s#/var/log/messages {}.*# #g" /etc/logrotate.conf

ENV NODE_VERSION 14.18.1
RUN case "${QEMU_ARCH}" in \
x86_64) NODE_ARCH='x64';; \
arm) NODE_ARCH='armv7l';; \
Expand Down

0 comments on commit 65fee3b

Please sign in to comment.