-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c9222dc
Showing
13 changed files
with
1,169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
tags: | ||
- '*' | ||
|
||
concurrency: | ||
group: ${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
bake: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 360 | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- | ||
name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
driver-opts: | | ||
image=moby/buildkit:v0.11.1 | ||
network=host | ||
- | ||
name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Set TAG Environment Variable | ||
run: | | ||
echo "TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV | ||
- | ||
name: Build and push | ||
run: | | ||
docker buildx bake --builder ${{ steps.buildx.outputs.name }} ci --push | ||
docker buildx imagetools create -t islandora/nodejs:${TAG} islandora/nodejs:${TAG}-amd64 islandora/nodejs:${TAG}-arm64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
certs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Islandora | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# ISLE: NodeJS <!-- omit in toc --> | ||
|
||
[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](./LICENSE) | ||
[![CI](https://github.com/Islandora-Devops/isle-nodejs/actions/workflows/ci.yml/badge.svg)](https://github.com/Islandora-Devops/isle-nodejs/actions/workflows/ci.yml) | ||
|
||
- [Introduction](#introduction) | ||
- [Requirements](#requirements) | ||
- [Host-platform Builds](#host-platform-builds) | ||
- [Multi-platform builds](#multi-platform-builds) | ||
|
||
## Introduction | ||
|
||
This repository provides the `islandora/nodejs` image which only exists to | ||
provide a custom Alpine APK package(s). As `code-server` is often one or two | ||
versions behind what gets shipped with Alpine. | ||
|
||
Since this does not change often and takes a very long time to cross compile for | ||
both platforms it's been moved to it's own repository. | ||
|
||
## Requirements | ||
|
||
To build the Docker images using the provided Gradle build scripts requires: | ||
|
||
- [Docker 20+](https://docs.docker.com/get-docker/) | ||
|
||
## Host-platform Builds | ||
|
||
You can build your host platform locally using the default builder like so. | ||
|
||
```bash | ||
docker context use default | ||
docker buildx bake | ||
``` | ||
|
||
## Multi-platform builds | ||
|
||
To test multi-arch builds and remote build caching requires setting up a local | ||
registry. | ||
|
||
Please use [isle-builder] to create a builder to simplify this process. Using | ||
the defaults provided, .e.g: | ||
|
||
``` | ||
make start | ||
``` | ||
|
||
After which you should be able to build with the following command: | ||
|
||
```bash | ||
REPOSITORY=islandora.io docker buildx bake --builder isle-builder ci --push | ||
``` | ||
|
||
[isle-builder]: https://github.com/Islandora-Devops/isle-builder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
############################################################################### | ||
# Variables | ||
############################################################################### | ||
variable "REPOSITORY" { | ||
default = "islandora" | ||
} | ||
|
||
variable "CACHE_FROM_REPOSITORY" { | ||
default = "islandora" | ||
} | ||
|
||
variable "CACHE_TO_REPOSITORY" { | ||
default = "islandora" | ||
} | ||
|
||
variable "TAG" { | ||
# "local" is to distinguish that from builds produced locally. | ||
default = "local" | ||
} | ||
|
||
variable "SOURCE_DATE_EPOCH" { | ||
default = "0" | ||
} | ||
|
||
############################################################################### | ||
# Functions | ||
############################################################################### | ||
function hostArch { | ||
params = [] | ||
result = equal("linux/amd64", BAKE_LOCAL_PLATFORM) ? "amd64" : "arm64" # Only two platforms supported. | ||
} | ||
|
||
function "tags" { | ||
params = [image, arch] | ||
result = ["${REPOSITORY}/${image}:${TAG}-${arch}"] | ||
} | ||
|
||
function "cacheFrom" { | ||
params = [image, arch] | ||
result = ["type=registry,ref=${CACHE_FROM_REPOSITORY}/cache:${image}-main-${arch}", "type=registry,ref=${CACHE_FROM_REPOSITORY}/cache:${image}-${TAG}-${arch}"] | ||
} | ||
|
||
function "cacheTo" { | ||
params = [image, arch] | ||
result = ["type=registry,oci-mediatypes=true,mode=max,compression=estargz,compression-level=5,ref=${CACHE_TO_REPOSITORY}/cache:${image}-${TAG}-${arch}"] | ||
} | ||
|
||
############################################################################### | ||
# Groups | ||
############################################################################### | ||
group "default" { | ||
targets = [ | ||
"nodejs" | ||
] | ||
} | ||
|
||
group "amd64" { | ||
targets = [ | ||
"nodejs-amd64", | ||
] | ||
} | ||
|
||
group "arm64" { | ||
targets = [ | ||
"nodejs-arm64", | ||
] | ||
} | ||
|
||
# CI should build both and push to the remote cache. | ||
group "ci" { | ||
targets = [ | ||
"nodejs-amd64-ci", | ||
"nodejs-arm64-ci", | ||
] | ||
} | ||
|
||
############################################################################### | ||
# Common target properties. | ||
############################################################################### | ||
target "common" { | ||
args = { | ||
# Required for reproduciable builds. | ||
# Requires Buildkit 0.11+ | ||
# See: https://reproducible-builds.org/docs/source-date-epoch/ | ||
SOURCE_DATE_EPOCH = "${SOURCE_DATE_EPOCH}", | ||
} | ||
} | ||
|
||
target "amd64-common" { | ||
platforms = ["linux/amd64"] | ||
} | ||
|
||
target "arm64-common" { | ||
platforms = ["linux/arm64"] | ||
} | ||
|
||
target "nodejs-common" { | ||
inherits = ["common"] | ||
context = "nodejs" | ||
contexts = { | ||
# The digest (sha256 hash) is not platform specific but the digest for the manifest of all platforms. | ||
# It will be the digest printed when you do: docker pull alpine:3.17.1 | ||
# Not the one displayed on DockerHub. | ||
# N.B. This should match the value used in: | ||
# - <https://github.com/Islandora-Devops/isle-imagemagick> | ||
# - <https://github.com/Islandora-Devops/isle-nodejs> | ||
alpine = "docker-image://alpine:3.19.1@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b" | ||
} | ||
} | ||
|
||
############################################################################### | ||
# Default Image targets for local builds. | ||
############################################################################### | ||
target "nodejs" { | ||
inherits = ["nodejs-common"] | ||
cache-from = cacheFrom("nodejs", hostArch()) | ||
tags = tags("nodejs", "") | ||
} | ||
|
||
############################################################################### | ||
# linux/amd64 targets. | ||
############################################################################### | ||
target "nodejs-amd64" { | ||
inherits = ["nodejs-common", "amd64-common"] | ||
cache-from = cacheFrom("nodejs", "amd64") | ||
tags = tags("nodejs", "amd64") | ||
} | ||
|
||
target "nodejs-amd64-ci" { | ||
inherits = ["nodejs-amd64"] | ||
cache-to = cacheTo("nodejs", "amd64") | ||
} | ||
|
||
############################################################################### | ||
# linux/arm64 targets. | ||
############################################################################### | ||
target "nodejs-arm64" { | ||
inherits = ["nodejs-common", "arm64-common"] | ||
cache-from = cacheFrom("nodejs", "arm64") | ||
tags = tags("nodejs", "arm64") | ||
} | ||
|
||
target "nodejs-arm64-ci" { | ||
inherits = ["nodejs-arm64"] | ||
cache-to = cacheTo("nodejs", "arm64") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
build.gradle.kts | ||
README.md | ||
tests | ||
tests/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# syntax=docker/dockerfile:1.5.1 | ||
FROM alpine | ||
|
||
ARG TARGETARCH | ||
|
||
RUN --mount=type=cache,id=abuild-apk-${TARGETARCH},sharing=locked,target=/var/cache/apk \ | ||
apk add \ | ||
alpine-sdk \ | ||
bash \ | ||
sudo \ | ||
&& \ | ||
adduser -G abuild -g "Alpine Package Builder" -s /bin/ash -D builder && \ | ||
echo "builder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
|
||
ENV PACKAGER="Nigel Banks <[email protected]>" | ||
|
||
USER builder | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
ARG TARGETARCH | ||
|
||
# Platform specific does require arch specific identifier. | ||
RUN --mount=type=bind,readwrite=true,source=build,target=/build \ | ||
--mount=type=cache,id=nodejs-apk-${TARGETARCH},sharing=locked,target=/var/cache/apk \ | ||
export PACKAGES=(\ | ||
brotli-dev \ | ||
c-ares-dev \ | ||
icu-dev \ | ||
linux-headers \ | ||
nghttp2-dev \ | ||
openssl-dev \ | ||
py3-jinja2 \ | ||
python3 \ | ||
samurai \ | ||
zlib-dev \ | ||
) && \ | ||
sudo apk add "${PACKAGES[@]}" && \ | ||
sudo mkdir -p /packages && \ | ||
sudo chown -R builder /build && \ | ||
cd /build && \ | ||
abuild-keygen -ain && \ | ||
abuild-apk update && \ | ||
abuild && \ | ||
sudo apk del "${PACKAGES[@]}" && \ | ||
sudo mv $(find /home/builder/packages/* -type f) /packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# NodeJS | ||
|
||
Docker image for `nodejs` package. | ||
|
||
It is not meant to be deployed as a service, but rather as base to import our | ||
custom nodejs build into containers like `islandora/code-server`. | ||
|
||
Consumers are expected to follow this pattern: | ||
|
||
```dockerfile | ||
FROM islandora/nodejs:latest as nodejs | ||
|
||
FROM some_image:latest | ||
|
||
RUN --mount=type=bind,from=nodejs,source=/home/builder/packages/x86_64,target=/packages \ | ||
--mount=type=bind,from=nodejs,source=/etc/apk/keys,target=/etc/apk/keys \ | ||
apk add /packages/nodejs-*.apk && \ | ||
... other build steps ... && \ | ||
cleanup.sh | ||
``` |
Oops, something went wrong.