Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]