Skip to content

Commit

Permalink
Initial proof of concept
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 Sep 17, 2024
1 parent a8a4fef commit 0fb6903
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 24 deletions.
93 changes: 84 additions & 9 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,87 @@
FROM amd64/debian:stable-slim
ENV GOTIFY_SERVER_PORT="80"
ARG DEBIAN=stable

# --- JS Builder ---

FROM debian:${DEBIAN} AS js-builder

ARG BUILD_JS=1
ARG NODE_OPTIONS
ENV DEBIAN_FRONTEND=noninteractive

COPY . /src/gotify

RUN if [ "$BUILD_JS" = "1" ]; then \
apt-get update && apt-get install -yq --no-install-recommends \
curl \
git \
nodejs \
npm && \
\
NODE_OPTIONS_DEFAULT=$(if node --help | grep -q -- "--openssl-legacy-provider"; then echo --openssl-legacy-provider; fi) && \
export NODE_OPTIONS=${NODE_OPTIONS:-$NODE_OPTIONS_DEFAULT} && \
echo "Using NODE_OPTIONS=$NODE_OPTIONS" && \
cd /src/gotify/ui && \
\
npm install -g yarn && \
\
yarn install && \
yarn build && \
\
cp -r /src/gotify/ui/build /target; \
\
else \
mkdir -p /target; \
fi

# --- Go Builder ---

FROM debian:${DEBIAN} AS builder

ARG BUILD_JS=1
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
COPY --from=js-builder /target /ui-build

RUN if [ "$BUILD_JS" = "1" ]; then \
cp -r --update /ui-build /src/gotify/ui/build; \
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 build ${GO_BUILD_FLAGS} -o /target/app/gotify-app"

FROM debian:${DEBIAN}-slim

# build-time configurable port
ARG GOTIFY_SERVER_EXPOSE=80
ENV GOTIFY_SERVER_PORT=$GOTIFY_SERVER_EXPOSE

WORKDIR /app
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -yq \
tzdata \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
ADD gotify-app /app/

RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -yq --no-install-recommends \
tzdata \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

HEALTHCHECK --interval=30s --timeout=5s --start-period=5s CMD curl --fail http://localhost:$GOTIFY_SERVER_PORT/health || exit 1
EXPOSE 80
EXPOSE $GOTIFY_SERVER_EXPOSE

COPY --from=builder /target /

ENTRYPOINT ["./gotify-app"]
5 changes: 0 additions & 5 deletions docker/Dockerfile.arm64

This file was deleted.

5 changes: 0 additions & 5 deletions docker/Dockerfile.armv7

This file was deleted.

5 changes: 0 additions & 5 deletions docker/Dockerfile.riscv64

This file was deleted.

0 comments on commit 0fb6903

Please sign in to comment.