From ce433f0c51c6ba5cbb277c5e7ea7bc3826495aec Mon Sep 17 00:00:00 2001 From: yusing Date: Fri, 29 Mar 2024 22:40:11 +0000 Subject: [PATCH] script update for auto version discovery, dockerfile fix for CI --- .github/workflows/docker-image.yml | 2 +- .github/workflows/go.yml | 2 +- Dockerfile | 13 ++++++++++--- docs/binary.md | 17 +++++++++++++++-- setup-binary.sh | 8 ++++---- version.txt | 1 + 6 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 version.txt diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b06366b..0aa23e3 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,7 +3,7 @@ name: Docker Image CI on: push: tags: - - "*.*.*" + - "*" jobs: build_and_push: runs-on: ubuntu-latest diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 2f4b93d..bd525a1 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -6,7 +6,7 @@ name: Go on: push: tags: - - "*.*.*" + - "*" jobs: build: diff --git a/Dockerfile b/Dockerfile index 50a3689..793807c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,24 @@ +FROM golang:1.22.1 as builder + +COPY go.mod /app/go.mod +COPY src/ /app/src +COPY Makefile /app +WORKDIR /app +RUN make get +RUN make build + FROM alpine:latest LABEL maintainer="yusing@6uo.me" RUN apk add --no-cache tzdata -RUN mkdir /app -COPY bin/go-proxy /app/ +COPY --from=builder /app/bin/go-proxy /app/ COPY templates/ /app/templates COPY schema/ /app/schema RUN chmod +x /app/go-proxy ENV DOCKER_HOST unix:///var/run/docker.sock ENV GOPROXY_DEBUG 0 -ENV GOPROXY_REDIRECT_HTTP 1 EXPOSE 80 EXPOSE 8080 diff --git a/docs/binary.md b/docs/binary.md index 5f4cdbc..68fcd89 100644 --- a/docs/binary.md +++ b/docs/binary.md @@ -6,9 +6,22 @@ 2. Run setup script + To specitfy a version _(optional)_ + + ```shell + export VERSION=latest # will be resolved into real version number + export VERSION= + ``` + + If you don't need web config editor + + ```shell + export SETUP_CODEMIRROR=0 + ``` + + Setup: + ```shell - export VERSION=latest - export SETUP_CODEMIRROR=1 # set to 0 if you don't need web config editor wget -qO- https://6uo.me/go-proxy-setup-binary | sudo bash ``` diff --git a/setup-binary.sh b/setup-binary.sh index ffd32b3..60eeafb 100644 --- a/setup-binary.sh +++ b/setup-binary.sh @@ -5,9 +5,9 @@ BIN_URL="${REPO_URL}/releases/download/${VERSION}/go-proxy" SRC_URL="${REPO_URL}/archive/refs/tags/${VERSION}.tar.gz" APP_ROOT="/opt/go-proxy/${VERSION}" -if [ -z "$VERSION" ]; then - echo "You must specify a version" - exit 1 +if [ -z "$VERSION" || "$VERSION" = "latest" ]; then + VERSION_URL="${REPO_URL}/raw/main/version.txt" + VERSION=$(wget -qO- "$VERSION_URL") fi if [ -d "$APP_ROOT" ]; then @@ -66,7 +66,7 @@ setup() { exit 1 fi # SETUP_CODEMIRROR = 1 - if [ "$SETUP_CODEMIRROR" = "1" ]; then + if [ "$SETUP_CODEMIRROR" != "0" ]; then make setup-codemirror || echo "make setup-codemirror failed, ignored" fi } diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..b300caa --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.4.4 \ No newline at end of file