Skip to content

Commit

Permalink
feat(superchain): also build a superchain image with Node 14 (#2741)
Browse files Browse the repository at this point in the history
For CDKv2, we want to require (and test) against a newer version of
Node. We've attempted to build multiple Node versions into a single
Docker image, but because we cannot control the entrypoint there is no
reliable way of switching between the Node versions at execution time.

Therefore, we will now build two versions of the "superchain" image.
The Node version built into each is controlled by the `NODE_VERSION`
build argument.

Workflow has been changed to build and push the following images:

* Nightlies:
    * `jsii/superchain:node10-nightly`
    * `jsii/superchain:node14-nightly`
    * `jsii/superchain:nightly` will remain an alias for `:node10-nightly`
* Releases:
    * `jsii/superchain:node10`
    * `jsii/superchain:node14`
    * `jsii/superchain:latest` will remain an alias for `:node10`.

---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
  • Loading branch information
rix0rrr authored Mar 26, 2021
1 parent 30e79c4 commit 6364d51
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 21 deletions.
50 changes: 35 additions & 15 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ jobs:
superchain:
name: jsii/superchain
runs-on: ubuntu-latest
strategy:
matrix:
node: ['10', '14']
env:
# Node version whose images will be aliased to 'nightly' and 'latest'
DEFAULT_NODE_MAJOR_VERSION: 10
steps:
- name: Check out
uses: actions/checkout@v2
Expand Down Expand Up @@ -53,31 +59,45 @@ jobs:
- name: Build Image
if: steps.should-run.outputs.result == 'true'
run: |-
docker build \
--pull \
--build-arg BUILD_TIMESTAMP="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--build-arg COMMIT_ID='${{ github.sha }}' \
--tag 'jsii/superchain:nightly' \
docker build \
--pull \
--build-arg BUILD_TIMESTAMP="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--build-arg COMMIT_ID='${{ github.sha }}' \
--build-arg NODE_MAJOR_VERSION=${{ matrix.node }} \
--tag "jsii/superchain:node${{ matrix.node }}-nightly" \
./superchain
- name: Test Image
if: steps.should-run.outputs.result == 'true'
run: |-
docker run \
--rm \
--tty \
--network=host \
-v${{ github.workspace }}:${{ github.workspace }} \
-w${{ github.workspace }} \
'jsii/superchain:nightly' \
docker run \
--rm \
--tty \
--network=host \
-v${{ github.workspace }}:${{ github.workspace }} \
-w${{ github.workspace }} \
"jsii/superchain:node${{ matrix.node }}-nightly" \
bash -c "yarn install --frozen-lockfile && yarn build && yarn test"
# Only when puhsing to main/release from now on
- name: Publish (nightly)
if: steps.should-run.outputs.result == 'true' && github.event_name == 'push' && github.ref != 'refs/heads/release'
run: |-
docker push jsii/superchain:nightly
docker push jsii/superchain:node${{ matrix.node }}-nightly
# If the current version is the default version, also tag this with the unqualified ':nightly' label
if [[ "${{ matrix.node }}" == "$DEFAULT_NODE_MAJOR_VERSION" ]]; then
docker tag jsii/superchain:node${{ matrix.node }}-nightly jsii/superchain:nightly
docker push jsii/superchain:nightly
fi
- name: Publish (latest)
if: steps.should-run.outputs.result == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/release'
run: |-
docker tag jsii/superchain:nightly jsii/superchain:latest
docker push jsii/superchain:latest
# Alias 'nodeX-nightly's to 'nodeX', then push
docker tag jsii/superchain:node${{ matrix.node }}-nightly jsii/superchain:node${{ matrix.node }}
docker push jsii/superchain:node${{ matrix.node }}
# If the current version is the default version, also tag this with the unqualified ':latest' label
if [[ "${{ matrix.node }}" == "$DEFAULT_NODE_MAJOR_VERSION" ]]; then
docker tag jsii/superchain:node${{ matrix.node }} jsii/superchain:latest
docker push jsii/superchain:latest
fi
6 changes: 3 additions & 3 deletions .mergify/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pull_request_rules:
- '#changes-requested-reviews-by=0'
- status-success=Semantic Pull Request
# Docker image validation
- status-success=jsii/superchain
- status-success~=^jsii/superchain
# One test for each OS
- status-success~=^Test \(ubuntu-.*$
- status-success~=^Test \(macos-.*$
Expand Down Expand Up @@ -79,7 +79,7 @@ pull_request_rules:
- '#changes-requested-reviews-by=0'
- status-success=Semantic Pull Request
# Docker image validation
- status-success=jsii/superchain
- status-success~=^jsii/superchain
# One test for each OS
- status-success~=^Test \(ubuntu-.*$
- status-success~=^Test \(macos-.*$
Expand Down Expand Up @@ -128,7 +128,7 @@ pull_request_rules:
- '#changes-requested-reviews-by=0'
- status-success=Semantic Pull Request
# Docker image validation
- status-success=jsii/superchain
- status-success~=^jsii/superchain
# One test for each OS
- status-success~=^Test \(ubuntu-.*$
- status-success~=^Test \(macos-.*$
Expand Down
8 changes: 6 additions & 2 deletions superchain/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ RUN amazon-linux-extras install docker
&& yum clean all && rm -rf /var/cache/yum
VOLUME /var/lib/docker

# Install Node 10+
RUN curl -sL https://rpm.nodesource.com/setup_10.x | bash - \
# Install Node 10+ (configurable with '--build-arg NODE_MAJOR_VERSION=xxx')
# (Put this as late as possible in the Dockerfile so we get to reuse the layer cache
# for most of the multiple builds).
ARG NODE_MAJOR_VERSION=10

RUN curl -sL https://rpm.nodesource.com/setup_${NODE_MAJOR_VERSION}.x | bash - \
&& yum -y install nodejs \
&& yum clean all && rm -rf /var/cache/yum \
&& npm set unsafe-perm true
Expand Down
21 changes: 20 additions & 1 deletion superchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,30 @@ SDK | Version
`OpenJDK 8` | Amazon Corretto `>= 8.242.08.1`
`.NET SDK` | `>= 3.1.101`
`mono` | `>= 6.8.0.105`
`Javascript` | `node >= 10.19.0` with `npm >= 6.13.4`
`Javascript` | `node >= 10.19.0` OR `node >= 14.16.0` with `npm >= 6.14.11` (see [NodeJS and NPM](#nodejs-and-npm))
`PowerShell` | `pwsh >= 6.2.3`
`Python 3` | `python3 >= 3.7.4` with `pip3 >= 20.0.2`
`Go` | `go >= 1.16`

## NodeJS and NPM

We build multiple versions of this image, for different versions of Node. They are available as:

* `jsii/superchain:node10[-nightly]`
* `jsii/superchain:node14[-nightly]`

The following labels are also available, and are aliases for the Node 10 images:

* `jsii/superchain:nightly`
* `jsii/superchain:latest`

If you are building this image from source, you can control the Node version with the
`NODE_MAJOR_VERSION` build argument:

```
docker build [...] --build-arg NODE_MAJOR_VERSION=14 .
```

## Included Tools & Utilities

Tool / Utility | Version
Expand Down
1 change: 1 addition & 0 deletions superchain/build-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ docker build
--pull \
--build-arg BUILD_TIMESTAMP=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg COMMIT_ID=${COMMIT_ID} \
--build-arg NODE_MAJOR_VERSION=10 \
-t "jsii/superchain:local" \
.

0 comments on commit 6364d51

Please sign in to comment.