Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: build upgrade for aarch64/arm64 architecture #1399

Merged
merged 3 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/shadowbox/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ COPY scripts scripts/
COPY src src/
COPY tsconfig.json ./
COPY third_party third_party
RUN ROOT_DIR=/ npm run action shadowbox/server/build

ARG ARCH

RUN ARCH=${ARCH} ROOT_DIR=/ npm run action shadowbox/server/build

# shadowbox image
FROM ${NODE_IMAGE}
Expand Down
15 changes: 14 additions & 1 deletion src/shadowbox/docker/build.action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,29 @@ export DOCKER_CONTENT_TRUST="${DOCKER_CONTENT_TRUST:-1}"
# Enable Docker BuildKit (https://docs.docker.com/develop/develop-images/build_enhancements)
export DOCKER_BUILDKIT=1

# Docker image build architecture. Supported architectures: x86_64, arm64
export ARCH=${ARCH:-x86_64}

# Newer node images have no valid content trust data.
# Pin the image node:16.18.0-alpine3.16 by hash.
# See image at https://hub.docker.com/_/node/tags?page=1&name=16.18.0-alpine3.16
readonly NODE_IMAGE="node@sha256:264861cd2f785a2b727e9f908065e8d9e9358fcc1308da3cb207d9cba69afee2"
readonly NODE_IMAGE=$(
if [[ "${ARCH}" == "x86_64" ]]; then
echo "node@sha256:264861cd2f785a2b727e9f908065e8d9e9358fcc1308da3cb207d9cba69afee2"
elif [[ "${ARCH}" == "arm64" ]]; then
echo "node@sha256:e2aff82eea79469af43ddd121f1c8f8c91a501e838534bd3991e225401b2c38d"
else
echo "Unsupported architecture"
exit 1
fi
)

# Doing an explicit `docker pull` of the container base image to work around an issue where
# Travis fails to pull the base image when using BuildKit. Seems to be related to:
# https://github.com/moby/buildkit/issues/606 and https://github.com/moby/buildkit/issues/1397
docker pull "${NODE_IMAGE}"
docker build --force-rm \
--build-arg ARCH="${ARCH}" \
--build-arg NODE_IMAGE="${NODE_IMAGE}" \
--build-arg GITHUB_RELEASE="${TRAVIS_TAG:-none}" \
-f src/shadowbox/docker/Dockerfile \
Expand Down
9 changes: 5 additions & 4 deletions src/shadowbox/server/build.action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ webpack --config=src/shadowbox/webpack.config.js ${BUILD_ENV:+--mode="${BUILD_EN

# Install third_party dependencies
readonly OS="$([[ "$(uname)" == "Darwin" ]] && echo "macos" || echo "linux")"
export ARCH=${ARCH:-x86_64}
readonly BIN_DIR="${OUT_DIR}/bin"
mkdir -p "${BIN_DIR}"
{
cd "${ROOT_DIR}/third_party/prometheus"
make "bin/${OS}/prometheus"
cp "bin/${OS}/prometheus" "${BIN_DIR}/"
make "bin/${OS}-${ARCH}/prometheus"
cp "bin/${OS}-${ARCH}/prometheus" "${BIN_DIR}/"
}
{
cd "${ROOT_DIR}/third_party/outline-ss-server"
make "bin/${OS}/outline-ss-server"
cp "bin/${OS}/outline-ss-server" "${BIN_DIR}/"
make "bin/${OS}-${ARCH}/outline-ss-server"
cp "bin/${OS}-${ARCH}/outline-ss-server" "${BIN_DIR}/"
}

# Copy shadowbox package.json
Expand Down
18 changes: 12 additions & 6 deletions third_party/outline-ss-server/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
VERSION=1.4.0

.PHONY: all
all: bin/linux/outline-ss-server bin/macos/outline-ss-server
all: bin/linux-x86_64/outline-ss-server bin/linux-arm64/outline-ss-server bin/macos-x86_64/outline-ss-server bin/macos-arm64/outline-ss-server

bin/linux/outline-ss-server: OS=linux
bin/linux/outline-ss-server: SHA256=f51bcb6391cca0ae828620c429e698a3b7c409de2374c52f113ca9a525e021a8
bin/linux-x86_64/outline-ss-server: OS=linux
bin/linux-x86_64/outline-ss-server: SHA256=f51bcb6391cca0ae828620c429e698a3b7c409de2374c52f113ca9a525e021a8

bin/macos/outline-ss-server: OS=macos
bin/macos/outline-ss-server: SHA256=c85b2e8ae2d48482cbc101e54dcb7eed074a22c14a3a7301993e5f786b34081d
bin/linux-arm64/outline-ss-server: OS=linux
bin/linux-arm64/outline-ss-server: SHA256=14ae581414c9aab04253a385ef1854c003d09f545f6f8a3a55aa987f0c6d3859

bin/macos-x86_64/outline-ss-server: OS=macos
bin/macos-x86_64/outline-ss-server: SHA256=c85b2e8ae2d48482cbc101e54dcb7eed074a22c14a3a7301993e5f786b34081d

bin/macos-arm64/outline-ss-server: OS=macos
bin/macos-arm64/outline-ss-server: SHA256=9647712a7c732184f98b1e2e7f74281855afed2245ec922c4a24b54f0eb0ce72

TEMPFILE := $(shell mktemp)
bin/%/outline-ss-server:
node ../../src/build/download_file.mjs --url="https://github.com/Jigsaw-Code/outline-ss-server/releases/download/v$(VERSION)/outline-ss-server_$(VERSION)_$(OS)_x86_64.tar.gz" --out="$(TEMPFILE)" --sha256=$(SHA256)
node ../../src/build/download_file.mjs --url="https://github.com/Jigsaw-Code/outline-ss-server/releases/download/v$(VERSION)/outline-ss-server_$(VERSION)_$(OS)_$(ARCH).tar.gz" --out="$(TEMPFILE)" --sha256=$(SHA256)
mkdir -p "$(dir $@)"
tar -zx -f "$(TEMPFILE)" -C "$(dir $@)" "$(notdir $@)"
chmod +x "$@"
Expand Down
26 changes: 19 additions & 7 deletions third_party/prometheus/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
VERSION=2.37.1

ifeq ($(ARCH),x86_64)
APP_ARCH=amd64
else
APP_ARCH=arm64
endif

.PHONY: all
all: bin/linux/prometheus bin/macos/prometheus
all: bin/linux-x86_64/prometheus bin/linux-arm64/prometheus bin/macos-x86_64/prometheus bin/macos-arm64/prometheus

bin/linux-x86_64/prometheus: OS=linux
bin/linux-x86_64/prometheus: SHA256=753f66437597cf52ada98c2f459aa8c03745475c249c9f2b40ac7b3919131ba6

bin/linux-arm64/prometheus: OS=linux
bin/linux-arm64/prometheus: SHA256=b59a66fb5c7ec5acf6bf426793528a5789a1478a0dad8c64edc2843caf31b1b8

bin/linux/prometheus: OS=linux
bin/linux/prometheus: SHA256=753f66437597cf52ada98c2f459aa8c03745475c249c9f2b40ac7b3919131ba6
bin/macos-x86_64/prometheus: OS=darwin
bin/macos-x86_64/prometheus: SHA256=e03a43d98955ac3500f57353ea74b5df829074205f195ea6b3b88f55c4575c79

bin/macos/prometheus: OS=darwin
bin/macos/prometheus: SHA256=e03a43d98955ac3500f57353ea74b5df829074205f195ea6b3b88f55c4575c79
bin/macos-arm64/prometheus: OS=darwin
bin/macos-arm64/prometheus: SHA256=eb8a174c82a0fb6c84e81d9a73214318fb4a605115ad61505d7883d02e5a6f52

bin/%/prometheus: TEMPFILE := $(shell mktemp)
bin/%/prometheus:
node ../../src/build/download_file.mjs --url="https://github.com/prometheus/prometheus/releases/download/v$(VERSION)/prometheus-$(VERSION).$(OS)-amd64.tar.gz" --out="$(TEMPFILE)" --sha256=$(SHA256)
node ../../src/build/download_file.mjs --url="https://github.com/prometheus/prometheus/releases/download/v$(VERSION)/prometheus-$(VERSION).$(OS)-$(APP_ARCH).tar.gz" --out="$(TEMPFILE)" --sha256=$(SHA256)
mkdir -p "$(dir $@)"
tar -zx -f "$(TEMPFILE)" --strip-components=1 -C "$(dir $@)" prometheus-$(VERSION).$(OS)-amd64/prometheus
tar -zx -f "$(TEMPFILE)" --strip-components=1 -C "$(dir $@)" prometheus-$(VERSION).$(OS)-$(APP_ARCH)/prometheus
chmod +x "$@"
rm -f $(TEMPFILE)

Expand Down
Loading