script update for auto version discovery, dockerfile fix for CI

This commit is contained in:
yusing 2024-03-29 22:40:11 +00:00
parent 486122f3d8
commit ce433f0c51
6 changed files with 32 additions and 11 deletions

View file

@ -3,7 +3,7 @@ name: Docker Image CI
on:
push:
tags:
- "*.*.*"
- "*"
jobs:
build_and_push:
runs-on: ubuntu-latest

View file

@ -6,7 +6,7 @@ name: Go
on:
push:
tags:
- "*.*.*"
- "*"
jobs:
build:

View file

@ -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

View file

@ -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=<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
```

View file

@ -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
}

1
version.txt Normal file
View file

@ -0,0 +1 @@
0.4.4