mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 13:23:09 +01:00
Optimize build time
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/.idea
|
||||
/*.iml
|
||||
|
||||
/.dev
|
||||
.dev
|
||||
/.git
|
||||
/.github
|
||||
/.res
|
||||
|
||||
24
.github/workflows/build.yml
vendored
24
.github/workflows/build.yml
vendored
@@ -4,7 +4,6 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'v*'
|
||||
tags:
|
||||
- 'v*'
|
||||
paths-ignore:
|
||||
@@ -15,7 +14,6 @@ on:
|
||||
pull_request:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'v*'
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- '.github/workflows/docs.yml'
|
||||
@@ -55,17 +53,6 @@ jobs:
|
||||
with:
|
||||
version: latest
|
||||
args: release --skip-publish --rm-dist
|
||||
-
|
||||
name: Test
|
||||
run: |
|
||||
go test -coverprofile=coverage.txt -covermode=atomic -race ./...
|
||||
-
|
||||
name: Upload coverage
|
||||
uses: codecov/codecov-action@v1
|
||||
if: success()
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
file: ./coverage.txt
|
||||
-
|
||||
name: GitHub Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
@@ -82,7 +69,6 @@ jobs:
|
||||
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
needs: go
|
||||
env:
|
||||
DOCKERHUB_SLUG: crazymax/diun
|
||||
GHCR_SLUG: ghcr.io/crazy-max/diun
|
||||
@@ -109,6 +95,14 @@ jobs:
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
buildkitd-flags: "--debug"
|
||||
-
|
||||
name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
-
|
||||
name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
@@ -140,6 +134,8 @@ jobs:
|
||||
org.opencontainers.image.title=Diun
|
||||
org.opencontainers.image.description=Docker image update notifier
|
||||
org.opencontainers.image.vendor=CrazyMax
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
|
||||
-
|
||||
name: Check manifest
|
||||
if: github.event_name != 'pull_request'
|
||||
|
||||
2
.github/workflows/docs.yml
vendored
2
.github/workflows/docs.yml
vendored
@@ -4,7 +4,6 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'v*'
|
||||
tags:
|
||||
- 'v*'
|
||||
paths:
|
||||
@@ -15,7 +14,6 @@ on:
|
||||
pull_request:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'v*'
|
||||
paths:
|
||||
- '.github/workflows/docs.yml'
|
||||
- 'docs/**'
|
||||
|
||||
57
.github/workflows/test.yml
vendored
Normal file
57
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
name: test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
tags:
|
||||
- 'v*'
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- '.github/workflows/docs.yml'
|
||||
- 'docs/**'
|
||||
- 'mkdocs.yml'
|
||||
pull_request:
|
||||
branches:
|
||||
- 'master'
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- '.github/workflows/docs.yml'
|
||||
- 'docs/**'
|
||||
- 'mkdocs.yml'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.13
|
||||
-
|
||||
name: Cache Go modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
-
|
||||
name: Go mod
|
||||
run: |
|
||||
go mod download
|
||||
-
|
||||
name: Test
|
||||
run: |
|
||||
go test -coverprofile=coverage.txt -covermode=atomic -race ./...
|
||||
-
|
||||
name: Upload coverage
|
||||
uses: codecov/codecov-action@v1
|
||||
if: success()
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
file: ./coverage.txt
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,5 +4,3 @@
|
||||
.dev
|
||||
/bin
|
||||
/dist
|
||||
|
||||
/site
|
||||
|
||||
34
Dockerfile
34
Dockerfile
@@ -1,29 +1,25 @@
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} tonistiigi/xx:golang AS xgo
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.13-alpine AS builder
|
||||
|
||||
ARG GO_VERSION=1.13
|
||||
ARG VERSION=dev
|
||||
|
||||
ENV CGO_ENABLED 0
|
||||
ENV GO111MODULE on
|
||||
ENV GOPROXY https://goproxy.io,direct
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} tonistiigi/xx:golang AS xgo
|
||||
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:${GO_VERSION}-alpine AS base
|
||||
RUN apk add --no-cache curl gcc git musl-dev
|
||||
COPY --from=xgo / /
|
||||
WORKDIR /src
|
||||
|
||||
RUN apk --update --no-cache add \
|
||||
build-base \
|
||||
gcc \
|
||||
git \
|
||||
&& rm -rf /tmp/* /var/cache/apk/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . ./
|
||||
FROM base AS gomod
|
||||
COPY . .
|
||||
RUN go mod download
|
||||
|
||||
FROM gomod AS build
|
||||
ARG TARGETPLATFORM
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
RUN go env
|
||||
RUN go build -ldflags "-w -s -X 'main.version=${VERSION}'" -v -o diun cmd/main.go
|
||||
ARG VERSION
|
||||
ENV CGO_ENABLED 0
|
||||
ENV GOPROXY https://goproxy.io,direct
|
||||
RUN go build -ldflags "-w -s -X 'main.version=${VERSION}'" -v -o /opt/diun cmd/main.go
|
||||
|
||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:latest
|
||||
LABEL maintainer="CrazyMax"
|
||||
@@ -33,8 +29,8 @@ RUN apk --update --no-cache add \
|
||||
libressl \
|
||||
&& rm -rf /tmp/* /var/cache/apk/*
|
||||
|
||||
COPY --from=builder /app/diun /usr/local/bin/diun
|
||||
COPY --from=builder /usr/local/go/lib/time/zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip
|
||||
COPY --from=build /opt/diun /usr/local/bin/diun
|
||||
COPY --from=build /usr/local/go/lib/time/zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip
|
||||
RUN diun --version
|
||||
|
||||
ENV DIUN_DB_PATH="/data/diun.db"
|
||||
|
||||
Reference in New Issue
Block a user