-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
130 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,57 @@ | ||
kind: pipeline | ||
name: ci | ||
|
||
steps: | ||
- name: fetch tags | ||
image: alpine/git | ||
commands: | ||
- git fetch --tags | ||
- git describe --tags --always > .version | ||
|
||
- name: test app | ||
image: ghcr.io/dopos/golang-alpine:v1.18.6-alpine3.16.2 | ||
commands: | ||
- go test -tags test -covermode=atomic -coverprofile=coverage.txt ./... | ||
- go vet ./... | ||
- apk add --no-cache curl bash git | ||
- curl -sS https://codecov.io/bash | bash | ||
- curl -sSL https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | ||
- chmod +x ./cc-test-reporter | ||
- ./cc-test-reporter format-coverage coverage.txt -t gocov -p $${DRONE_REPO_LINK#https://} | ||
- ./cc-test-reporter upload-coverage | ||
environment: | ||
CGO_ENABLED: 0 | ||
CODECOV_TOKEN: | ||
from_secret: my-codecov-token | ||
CC_TEST_REPORTER_ID: | ||
from_secret: my-codeclimate-token | ||
|
||
# lint this file | ||
# go run github.com/woodpecker-ci/woodpecker/cmd/cli lint | ||
|
||
variables: | ||
# - &build_plugin 'woodpeckerci/plugin-docker-buildx' | ||
- &build_plugin 'plugins/docker' | ||
- &golint_img 'golangci/golangci-lint:v1.53-alpine' | ||
- &golang_img 'ghcr.io/dopos/golang-alpine:v1.19.7-alpine3.17.2' | ||
- base_settings: &base_buildx_settings | ||
registry: it.elfire.ru | ||
repo: it.elfire.ru/${CI_REPO_OWNER}/${CI_REPO_NAME} | ||
|
||
clone: | ||
git: | ||
image: woodpeckerci/plugin-git | ||
settings: | ||
lfs: false | ||
tags: true | ||
|
||
pipeline: | ||
|
||
test: | ||
image: *golang_img | ||
commands: make test | ||
|
||
lint: | ||
image: *golint_img | ||
commands: golangci-lint run | ||
|
||
build: | ||
image: *golang_img | ||
commands: | ||
- make build-standalone | ||
|
||
publish-dryrun: | ||
image: *build_plugin | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
settings: | ||
<<: *base_buildx_settings | ||
dry_run: true | ||
|
||
publish: | ||
image: *build_plugin | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
settings: | ||
<<: *base_buildx_settings | ||
auto_tag: true | ||
custom_labels: org.opencontainers.image.version=${CI_COMMIT_TAG##v} | ||
username: ${CI_REPO_OWNER} | ||
password: | ||
from_secret: cb_token | ||
when: | ||
event: tag | ||
ref: refs/tags/v* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,31 @@ | ||
ARG GOLANG_VERSION | ||
ARG GOLANG_IMAGE=ghcr.io/dopos/golang-alpine | ||
ARG GOLANG_VERSION=v1.19.7-alpine3.17.2 | ||
ARG APP=webtail | ||
|
||
# FROM golang:$GOLANG_VERSION as builder | ||
#FROM ghcr.io/dopos/golang-alpine:v1.16.10-alpine3.14.2 as builder | ||
FROM golang:1.19.7-alpine3.17 as builder | ||
ARG TARGETARCH | ||
FROM --platform=$BUILDPLATFORM ${GOLANG_IMAGE}:${GOLANG_VERSION} as build | ||
|
||
# for docker.io/golang:1.18-alpine | ||
RUN apk --update add git | ||
ARG APP | ||
|
||
WORKDIR /opt/app | ||
COPY . /src/$APP | ||
WORKDIR /src/$APP | ||
|
||
# Cached layer | ||
COPY ./go.mod ./go.sum ./ | ||
|
||
RUN echo "Build for arch $TARGETARCH" | ||
|
||
# Sources dependent layer | ||
COPY ./ ./ | ||
RUN CGO_ENABLED=0 go test -timeout 10m -tags test -covermode=atomic -coverprofile=coverage.out ./... | ||
RUN CGO_ENABLED=0 go build -ldflags "-X main.version=`git describe --tags --always`" -a ./cmd/webtail | ||
ARG GOPROXY TARGETOS TARGETARCH | ||
RUN --mount=type=cache,id=gobuild,target=/root/.cache/go-build \ | ||
--mount=type=cache,id=gomod,target=/go/pkg \ | ||
make build-standalone | ||
|
||
FROM scratch | ||
|
||
MAINTAINER Alexey Kovrizhkin <[email protected]> | ||
LABEL org.opencontainers.image.description "Tail [log]files via web[sockets]" | ||
LABEL org.opencontainers.image.title="webtail" \ | ||
org.opencontainers.image.description="Tail [log]files via web[sockets]" \ | ||
org.opencontainers.image.authors="[email protected]" \ | ||
org.opencontainers.image.licenses="MIT" | ||
|
||
VOLUME /data | ||
WORKDIR / | ||
COPY --from=builder /opt/app/webtail . | ||
|
||
ARG APP | ||
|
||
COPY --from=build /src/$APP/$APP /app | ||
EXPOSE 8080 | ||
ENTRYPOINT ["/webtail"] | ||
ENTRYPOINT [ "/app" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters