Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Conversation

@appleboy
Copy link
Contributor

Improve docker build speed. See the repo: https://github.com/go-training/docker-in-github-actions-vs-drone

FROM golang:1.14-alpine

LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>"

RUN apk add bash ca-certificates git gcc g++ libc-dev
WORKDIR /app
# Force the go compiler to use modules
ENV GO111MODULE=on
# We want to populate the module cache based on the go.{mod,sum} files.
COPY go.mod .
COPY go.sum .
COPY main.go .

ENV GOOS=linux
ENV GOARCH=amd64
RUN go build -o /app -tags netgo -ldflags '-w -extldflags "-static"' .

CMD ["/app"]

GitHub Actions

- name: build and push image
  uses: docker/build-push-action@v1
  with:
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKER_PASSWORD }}
    repository: appleboy/gin-docker-demo
    dockerfile: Dockerfile
    always_pull: true
    tags: latest

Drone CI

- name: publish
  pull: always
  image: plugins/docker:linux-amd64
  settings:
    auto_tag: true
    cache_from: appleboy/gin-docker-demo
    daemon_off: false
    dockerfile: Dockerfile
    password:
      from_secret: docker_password
    repo: appleboy/gin-docker-demo
    username:
      from_secret: docker_username
  when:
    event:
      exclude:
      - pull_request

Summary

build time

  • GitHub Actions: 1m10s (logs)
  • Drone CI: 17s (logs)

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
@zappy-shu
Copy link
Collaborator

Apologies for getting back to you so slowly. Thanks for opening this PR, cache support is something we want to add.

One thing I'd suggest is to allow multiple --cache-from. The option can be used multiple times to give a list of cached images. As github actions doesn't allow for list or complex object inputs the way we've been handling these kind of options is by using a comma-delimited list (see how --build-arg is handled).

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
@appleboy
Copy link
Contributor Author

@zappy-shu Done. See the commit f05453c

@zappy-shu
Copy link
Collaborator

Looks good. Could you also add a line to the build->inputs table in the readme: https://github.com/docker/github-actions#inputs-1

Afterwards I can merge and update the action include the new input

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
@appleboy
Copy link
Contributor Author

@zappy-shu Done

Copy link
Collaborator

@zappy-shu zappy-shu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@appleboy
Copy link
Contributor Author

@zappy-shu Can you merge this feature? Maybe fix the docker/build-push-action#7 issue?

@zappy-shu zappy-shu merged commit 0f18e2a into docker-archive:master Apr 22, 2020
@appleboy appleboy deleted the cache branch April 22, 2020 16:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants