add ability to build for arm64

This commit is contained in:
rubikscraft 2022-09-02 12:23:18 +02:00
parent 2519afae6a
commit 66342025d9
No known key found for this signature in database
GPG key ID: 1463EBE9200A5CD4
2 changed files with 23 additions and 15 deletions

View file

@ -2,26 +2,34 @@
PACKAGE_URL="ghcr.io/rubikscraft/picsur"
if [ "$1" == "alpha" ]; then
PACKAGE_URL="$PACKAGE_URL-alpha"
elif [ "$1" == "stable" ]; then
true;
else
echo "Usage: $0 [alpha|stable]"
exit 1
fi
# Go to this script
cd "$(dirname "${BASH_SOURCE[0]}")"
# Install binfmt
docker run --privileged --rm tonistiigi/binfmt --install all
# Read current version from ../package.json
VERSION=$(cat ../package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
echo "Building version $VERSION"
docker build -t "$PACKAGE_URL:$VERSION" -t "$PACKAGE_URL:latest" -f ./picsur.Dockerfile ..
docker buildx create --append --use --name picsur
echo "Done"
docker buildx build \
--platform linux/amd64,linux/arm64 \
--push \
-t "$PACKAGE_URL:$VERSION" \
-t "$PACKAGE_URL:latest" \
-f ./picsur.Dockerfile ..
# only push if argument is set to "push"
if [ "$1" == "push" ]; then
echo "Pushing to registry"
docker push "$PACKAGE_URL:$VERSION"
docker push "$PACKAGE_URL:latest"
echo "Done"
else
echo "Not pushing to registry"
fi
echo "Done pushing $PACKAGE_URL:$VERSION"

View file

@ -1,4 +1,4 @@
FROM node:18.8-bullseye
FROM node:18.8
# Sorry for the humongous docker container this generates
# Maybe I'll trim it down some day
@ -14,4 +14,4 @@ RUN yarn workspace picsur-shared build
RUN yarn workspace picsur-frontend build
RUN yarn workspace picsur-backend build
CMD /bin/bash -c "yarn workspace picsur-backend start:prod"
CMD yarn workspace picsur-backend start:prod