diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..2429f6e --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,25 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go + +on: + push: + branches: [ "master" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + - name: Vverify dependencies + run: go mod verify + + - name: Build + run: go build -v ./cmd/main.go diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3842796 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM golang:alpine as app-builder +WORKDIR $GOPATH/src/ticket-creator/ +COPY . . +RUN apk add git +# Static build required so that we can safely copy the binary over. +# `-tags timetzdata` embeds zone info from the "time/tzdata" package. +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go install -ldflags '-extldflags "-static"' -tags timetzdata cmd/main.go + +FROM scratch +# the test program: +COPY --from=app-builder /go/bin/main /ticket-creator +COPY --from=app-builder /go/src/ticket-creator/cmd/.env / +# the tls certificates: +# NB: this pulls directly from the upstream image, which already has ca-certificates: +COPY --from=alpine:latest /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +ENTRYPOINT ["/ticket-creator"] \ No newline at end of file diff --git a/cmd/main.go b/cmd/main.go index 1bc3d08..28682b9 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -19,7 +19,8 @@ import ( ) func main() { - env(".env.dev") + log.Print("started") + env(".env") ctx := context.Background() ctx, cancel := signal.NotifyContext(ctx, os.Interrupt, os.Kill, syscall.SIGTERM) diff --git a/todo.md b/readme.md similarity index 78% rename from todo.md rename to readme.md index 884a4ed..fa80d83 100644 --- a/todo.md +++ b/readme.md @@ -1,16 +1,20 @@ -# Основное: + +`docker build -t golang-scratch-test --pull .` + +# To-do P1: - [ ] Делать запросы в Git, ownCloud параллельно; -- [ ] Команда для проверки работоспособности бота в проде; -- [x] Сделать бота в Telegram; -- [x] Сохранять правильную ссылку на GitBuild; - [x] Сохранять правильную ссылку на Git; +- [x] Сохранять правильную ссылку на GitBuild; +- [x] Сделать бота в Telegram; -# Под звёздочкой: +# To-do P2*: - [ ] Сохранять короткую ссылку на графику; - [ ] Сохранять внешнюю ссылку на графику; - [ ] Сделать бота в Discord; - [ ] Подумать над нормальной обработкой ошибок, сейчас достаточно всрато; - [ ] Складывать в описание репозитория ссылку на тикет; -- [ ] Сделать базулю с достойными пользователями; \ No newline at end of file +- [ ] Сделать базулю с достойными пользователями; + +- [x] Run bot on docker scratch: https://github.com/jeremyhuiskamp/golang-docker-scratch/blob/main/README.md \ No newline at end of file