diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index 6ce346f..f64edbd 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -23,6 +23,13 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Get latest code-server version + id: get_version + run: | + VERSION=$(curl -sX GET https://api.github.com/repos/coder/code-server/releases/latest \ + | awk '/tag_name/{print $4;exit}' FS='[""]' | sed 's|^v||') + echo "::set-output name=version::$VERSION" + - name: Build and push amd64 image uses: docker/build-push-action@v2 with: @@ -30,7 +37,9 @@ jobs: context: . platforms: linux/amd64 push: true - tags: martinussuherman/alpine-code-server:3.12.0-alpine3.13-amd64, martinussuherman/alpine-code-server:3.12.0-alpine3.13, martinussuherman/alpine-code-server:latest + tags: | + martinussuherman/alpine-code-server:${{ steps.get_version.outputs.version }}-amd64 + martinussuherman/alpine-code-server:latest - name: Build and push arm64v8 image uses: docker/build-push-action@v2 @@ -39,4 +48,4 @@ jobs: context: . platforms: linux/arm64 push: true - tags: martinussuherman/alpine-code-server:3.12.0-alpine3.13-arm64v8 + tags: martinussuherman/alpine-code-server:${{ steps.get_version.outputs.version }}-arm64v8 diff --git a/.github/workflows/snyk-docker-amd64.yml b/.github/workflows/snyk-docker-amd64.yml index a5857a5..48b6e85 100644 --- a/.github/workflows/snyk-docker-amd64.yml +++ b/.github/workflows/snyk-docker-amd64.yml @@ -32,6 +32,6 @@ jobs: args: --file=amd64/Dockerfile - name: Upload result to GitHub Code Scanning - uses: github/codeql-action/upload-sarif@v1 + uses: github/codeql-action/upload-sarif@v3 with: sarif_file: snyk.sarif diff --git a/amd64/Dockerfile b/amd64/Dockerfile index 4a08e57..48e0ff0 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -12,9 +12,7 @@ ENV \ # should user shell set to nologin? (yes/no) \ ENOLOGIN=no \ # container user home dir \ - EHOME=/home/vscode \ - # code-server version \ - VERSION=3.12.0 + EHOME=/home/vscode COPY code-server /usr/bin/ RUN chmod +x /usr/bin/code-server @@ -29,15 +27,15 @@ RUN \ nodejs \ openssh-client -RUN \ - wget https://github.com/cdr/code-server/releases/download/v$VERSION/code-server-$VERSION-linux-amd64.tar.gz && \ - tar x -zf code-server-$VERSION-linux-amd64.tar.gz && \ - rm code-server-$VERSION-linux-amd64.tar.gz && \ - rm code-server-$VERSION-linux-amd64/node && \ - rm code-server-$VERSION-linux-amd64/code-server && \ - rm code-server-$VERSION-linux-amd64/lib/node && \ - mv code-server-$VERSION-linux-amd64 /usr/lib/code-server && \ - sed -i 's/"$ROOT\/lib\/node"/node/g' /usr/lib/code-server/bin/code-server +RUN \ + export VERSION=$(curl -sX GET https://api.github.com/repos/coder/code-server/releases/latest | awk '/tag_name/{print $4;exit}' FS='[""]' | sed 's|^v||') && \ + echo "******************" && \ + echo "Version : $VERSION" && \ + echo "******************" && \ + curl -fsSL -o code-server-${VERSION}-linux-amd64.tar.gz https://github.com/coder/code-server/releases/download/v${VERSION}/code-server-${VERSION}-linux-amd64.tar.gz && \ + tar -zxf code-server-${VERSION}-linux-amd64.tar.gz && \ + rm code-server-${VERSION}-linux-amd64.tar.gz && \ + mv code-server-${VERSION}-linux-amd64 /usr/lib/code-server ENTRYPOINT ["entrypoint-su-exec", "code-server"] CMD ["--bind-addr 0.0.0.0:8080"] diff --git a/arm64v8/Dockerfile b/arm64v8/Dockerfile index 34d5f03..6ae3a7d 100644 --- a/arm64v8/Dockerfile +++ b/arm64v8/Dockerfile @@ -12,9 +12,7 @@ ENV \ # should user shell set to nologin? (yes/no) \ ENOLOGIN=no \ # container user home dir \ - EHOME=/home/vscode \ - # code-server version \ - VERSION=3.12.0 + EHOME=/home/vscode COPY code-server /usr/bin/ RUN chmod +x /usr/bin/code-server @@ -30,14 +28,14 @@ RUN \ openssh-client RUN \ - wget https://github.com/cdr/code-server/releases/download/v$VERSION/code-server-$VERSION-linux-arm64.tar.gz && \ - tar x -zf code-server-$VERSION-linux-arm64.tar.gz && \ - rm code-server-$VERSION-linux-arm64.tar.gz && \ - rm code-server-$VERSION-linux-arm64/node && \ - rm code-server-$VERSION-linux-arm64/code-server && \ - rm code-server-$VERSION-linux-arm64/lib/node && \ - mv code-server-$VERSION-linux-arm64 /usr/lib/code-server && \ - sed -i 's/"$ROOT\/lib\/node"/node/g' /usr/lib/code-server/bin/code-server + export VERSION=$(curl -sX GET https://api.github.com/repos/coder/code-server/releases/latest | awk '/tag_name/{print $4;exit}' FS='[""]' | sed 's|^v||') && \ + echo "******************" && \ + echo "Version : $VERSION" && \ + echo "******************" && \ + curl -fsSL -o code-server-${VERSION}-linux-arm64.tar.gz https://github.com/coder/code-server/releases/download/v${VERSION}/code-server-${VERSION}-linux-arm64.tar.gz && \ + tar -zxf code-server-${VERSION}-linux-arm64.tar.gz && \ + rm code-server-${VERSION}-linux-arm64.tar.gz && \ + mv code-server-${VERSION}-linux-arm64 /usr/lib/code-server ENTRYPOINT ["entrypoint-su-exec", "code-server"] CMD ["--bind-addr 0.0.0.0:8080"]