Skip to content

Commit

Permalink
Merge in gotify/build image
Browse files Browse the repository at this point in the history
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
  • Loading branch information
eternal-flame-AD committed Oct 16, 2024
1 parent decd463 commit 721aecf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 37 deletions.
44 changes: 22 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,33 @@ package-zip: extract-licenses
zip -ur $$BUILD.zip ${LICENSE_DIR}; \
done

build-docker-amd64: require-version
cp ${BUILD_DIR}/gotify-linux-amd64 ./docker/gotify-app
cd ${DOCKER_DIR} && \
docker build \
build-docker-multiarch: require-version
docker buildx build --sbom=true \
-t gotify/server:latest \
-t gotify/server:${VERSION} \
-t gotify/server:$(shell echo $(VERSION) | cut -d '.' -f -2) \
-t gotify/server:$(shell echo $(VERSION) | cut -d '.' -f -1) \
-t ghcr.io/gotify/server:latest \
-t ghcr.io/gotify/server:latest \
-t ghcr.io/gotify/server:${VERSION} \
-t ghcr.io/gotify/server:$(shell echo $(VERSION) | cut -d '.' -f -2) \
-t ghcr.io/gotify/server:$(shell echo $(VERSION) | cut -d '.' -f -1) .
rm ${DOCKER_DIR}gotify-app
-t ghcr.io/gotify/server:$(shell echo $(VERSION) | cut -d '.' -f -1) \
-t gotify/server-arm64:latest \
-t gotify/server-arm64:${VERSION} \
-t gotify/server-arm64:$(shell echo $(VERSION) | cut -d '.' -f -2) \
-t gotify/server-arm64:$(shell echo $(VERSION) | cut -d '.' -f -1) \
-t ghcr.io/gotify/server-arm64:latest \
-t ghcr.io/gotify/server-arm64:${VERSION} \
-t ghcr.io/gotify/server-arm64:$(shell echo $(VERSION) | cut -d '.' -f -2) \
-t ghcr.io/gotify/server-arm64:$(shell echo $(VERSION) | cut -d '.' -f -1) \
--build-arg GO_VERSION=$(shell cat GO_VERSION) \
--platform linux/amd64,linux/arm64,linux/386 \
-f docker/Dockerfile .

build-docker-amd64: build-docker-multiarch

build-docker-i386: build-docker-multiarch

build-docker-arm64: build-docker-multiarch

build-docker-arm-7: require-version
cp ${BUILD_DIR}/gotify-linux-arm-7 ./docker/gotify-app
Expand All @@ -91,20 +105,6 @@ build-docker-arm-7: require-version
-t ghcr.io/gotify/server-arm7:$(shell echo $(VERSION) | cut -d '.' -f -1) .
rm ${DOCKER_DIR}gotify-app

build-docker-arm64: require-version
cp ${BUILD_DIR}/gotify-linux-arm64 ./docker/gotify-app
cd ${DOCKER_DIR} && \
docker build -f Dockerfile.arm64 \
-t gotify/server-arm64:latest \
-t gotify/server-arm64:${VERSION} \
-t gotify/server-arm64:$(shell echo $(VERSION) | cut -d '.' -f -2) \
-t gotify/server-arm64:$(shell echo $(VERSION) | cut -d '.' -f -1) \
-t ghcr.io/gotify/server-arm64:latest \
-t ghcr.io/gotify/server-arm64:${VERSION} \
-t ghcr.io/gotify/server-arm64:$(shell echo $(VERSION) | cut -d '.' -f -2) \
-t ghcr.io/gotify/server-arm64:$(shell echo $(VERSION) | cut -d '.' -f -1) .
rm ${DOCKER_DIR}gotify-app

build-docker-riscv64: require-version
cp ${BUILD_DIR}/gotify-linux-riscv64 ./docker/gotify-app
cd ${DOCKER_DIR} && \
Expand All @@ -119,7 +119,7 @@ build-docker-riscv64: require-version
-t ghcr.io/gotify/server-riscv64:$(shell echo $(VERSION) | cut -d '.' -f -1) .
rm ${DOCKER_DIR}gotify-app

build-docker: build-docker-amd64 build-docker-arm-7 build-docker-arm64 build-docker-riscv64
build-docker: build-docker-multiarch build-docker-arm-7 build-docker-riscv64

build-js:
(cd ui && NODE_OPTIONS="${NODE_OPTIONS}" yarn build)
Expand Down
24 changes: 9 additions & 15 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
ARG DEBIAN=stable-slim
# supprress warnung about invalid variable expansion
ARG GO_VERSION=PLEASE_PROVIDE_GO_VERSION

# --- JS Builder ---

FROM debian:${DEBIAN} AS js-builder
FROM --platform=${BUILDPLATFORM} debian:${DEBIAN} AS js-builder

ARG BUILD_JS=1
ARG BUILD_JS=0
ARG NODE_OPTIONS
ENV DEBIAN_FRONTEND=noninteractive

Expand Down Expand Up @@ -35,21 +37,15 @@ RUN if [ "$BUILD_JS" = "1" ]; then \

# --- Go Builder ---

FROM debian:${DEBIAN} AS builder
FROM --platform=${BUILDPLATFORM} gotify/build:${GO_VERSION}-${TARGETPLATFORM/\//-} AS builder

ARG BUILD_JS=1
ARG RUN_TESTS=1
ARG BUILD_JS=0
ARG RUN_TESTS=0
ARG GO_BUILD_FLAGS=-mod=readonly -a -installsuffix cgo
ENV DEBIAN_FRONTEND=noninteractive

ADD https://raw.githubusercontent.com/travis-ci/gimme/master/gimme /usr/local/bin/gimme

RUN chmod +x /usr/local/bin/gimme # compatiblity

RUN apt-get update && apt-get install -yq --no-install-recommends \
build-essential \
ca-certificates \
curl \
git

COPY . /src/gotify
Expand All @@ -60,11 +56,9 @@ RUN if [ "$BUILD_JS" = "1" ]; then \
fi

RUN cd /src/gotify && \
read -r GIMME_GO_VERSION < GO_VERSION && \
echo "Using Go version: $GIMME_GO_VERSION" && \
gimme ${GIMME_GO_VERSION} && \
mkdir -p /target/app && \
bash -c ". ~/.gimme/envs/go${GIMME_GO_VERSION}.env && go test -v ./... && go build ${GO_BUILD_FLAGS} -o /target/app/gotify-app"
[ "$RUN_TESTS" = "1" ] && go test -v ./... || true && \
go build ${GO_BUILD_FLAGS} -o /target/app/gotify-app

FROM debian:${DEBIAN}

Expand Down

0 comments on commit 721aecf

Please sign in to comment.