diff --git a/.github/workflows/go-ci.yml b/.github/workflows/go-ci.yml new file mode 100644 index 0000000..b092da1 --- /dev/null +++ b/.github/workflows/go-ci.yml @@ -0,0 +1,45 @@ +name: Run Tests + +on: + push: + branches: [ '*' ] + pull_request: + branches: [ '*' ] + +jobs: +# lint: +# runs-on: ubuntu-latest +# steps: +# - name: Setup go +# uses: actions/setup-go@v2 +# with: +# go-version: '1.18' +# - name: Checkout repository +# uses: actions/checkout@v2 +# - name: Setup golangci-lint +# uses: golangci/golangci-lint-action@v3.2.0 +# with: +# version: v1.45.0 +# args: --verbose + test: + name: build and test + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + - name: Checkout Code + uses: actions/checkout@v2 + + - name: download dependencies + run: go get + + - name: Run Tests + run: go test ./... + + + +# - name: Upload coverage to Codecov +# uses: codecov/codecov-action@v2 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2f40c71 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM golang:1.18.1-alpine as builder + +WORKDIR /build + +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \ + apk update --no-cache && apk add --no-cache gcc musl-dev + +COPY go.mod . +COPY go.sum . +RUN go env -w GOPROXY=https://goproxy.cn,direct && go mod download +COPY . . +RUN go build -ldflags="-s -w" -o /app/httpserver ./main.go + +FROM alpine + +ENV TZ Asia/Shanghai +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \ + apk update --no-cache && apk add --no-cache ca-certificates + +WORKDIR /app +COPY --from=builder /app/httpserver ./httpserver + +EXPOSE 8000 + +CMD [ "./httpserver", "-ip", "0.0.0.0" ] \ No newline at end of file