Skip to content

Commit

Permalink
Merge pull request #676 from tonistiigi/dockerfile-release
Browse files Browse the repository at this point in the history
hack: add release script
  • Loading branch information
AkihiroSuda authored Oct 12, 2018
2 parents c7bb575 + 72ea6e2 commit 663f185
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bin
.tmp
release-out
30 changes: 28 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dist: trusty
sudo: required

install:
- docker run --name buildkit --rm -d --privileged -p 1234:1234 tonistiigi/buildkit --addr tcp://0.0.0.0:1234
- docker run --name buildkit --rm -d --privileged -p 1234:1234 $REPO_SLUG_ORIGIN --addr tcp://0.0.0.0:1234
- sudo docker cp buildkit:/usr/bin/buildctl /usr/bin/
- export BUILDKIT_HOST=tcp://0.0.0.0:1234

Expand All @@ -12,4 +12,30 @@ env:
- PREFER_BUILDCTL="1"

script:
- make binaries validate-all && ./hack/cross
- make binaries validate-all && ./hack/cross

before_deploy:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

deploy:
- provider: script
script: ./hack/release master $REPO_SLUG_TARGET push
on:
repo: moby/buildkit
branch: master
- provider: script
script: ./hack/release $TRAVIS_TAG $REPO_SLUG_TARGET push && PLATFORMS="${PLATFORMS},darwin/amd64,windows/amd64" ./hack/release-tar $TRAVIS_TAG release-out
on:
repo: moby/buildkit
tags: true
condition: $TRAVIS_TAG =~ ^v[0-9]
- provider: releases
api_key:
secure: "hA0L2F6O1MLEJEbUDzxokpO6F6QrAIkltmVG3g0tTAoVj1xtCOXSmH3cAnVbFYyOz9q8pa/85tbpyEEIHVlqvWk2a5/QS16QaBW6XxH+FiZ3oQ44JbtpsjpmBFxdhfeFs8Ca6Nj29AOtDx21HHWsZKlBZFvC4Ubc05AM1rgZpJyZVDvYsjZIunc8/CPCbvAAp6RLnLHxAYXF+TQ7mAZP2SewsW/61nPjPIp2P4d93CduA9kUSxtC/1ewmU2T9Ak2X1Nw2ecPTonGjO51xNa6Ebo1hsbsRt5Krd1IR5rSkgXqLrhQO+19J3sUrQr2p8su6hCTKXR5TQz9L5C9VG8T3yOLbA7/FKBndWgBCm7EB7SezhFkm91e3Phkd/Hi5PF4ZKUSKyOYORHpoeg7ggBXaQF5r0OolqvNjxe7EhE+zlUIqnk5eprVrXT8H1QDF0Jg7pfdqVV9AIZO6i+e+1wOVDaP6K6tiWGdkRFH0wahcucZ/8xVoa8JVNZKke2mMCuLGsNWcN4DeLhkxa6giw3tkqbnY+eTYcW/PyVFMAVsZ8rOjQu4u4mm82FYBI7UywWQJTReD1LO2ibxHk74nwtyauX7KsCPFh2CA27DKlsQ1/xkjaCpE6vduzKzPj2DSHp6tKjxn2edPWRI+/4JxLD6KUFX1f1KqD0pKy/qVsZhEPI="
file: release-out/**/*
skip_cleanup: true
file_glob: true
on:
repo: moby/buildkit
tags: true
condition: $TRAVIS_TAG =~ ^v[0-9]
1 change: 1 addition & 0 deletions cmd/buildctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func main() {
app := cli.NewApp()
app.Name = "buildctl"
app.Usage = "build utility"
app.Version = version.Version

defaultAddress := os.Getenv("BUILDKIT_HOST")
if defaultAddress == "" {
Expand Down
1 change: 1 addition & 0 deletions cmd/buildkitd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func main() {
app := cli.NewApp()
app.Name = "buildkitd"
app.Usage = "build daemon"
app.Version = version.Version

defaultConf, md := defaultConf()

Expand Down
2 changes: 1 addition & 1 deletion hack/dockerfiles/test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG CONTAINERD10_VERSION=v1.0.3
# available targets: buildkitd, buildkitd.oci_only, buildkitd.containerd_only
ARG BUILDKIT_TARGET=buildkitd
ARG REGISTRY_VERSION=2.6
ARG ROOTLESSKIT_VERSION=d843aadf00d72082fd7a31572ef018d1e792535f
ARG ROOTLESSKIT_VERSION=4f7ae4607d626f0a22fb495056d55b17cce8c01b

# The `buildkitd` stage and the `buildctl` stage are placed here
# so that they can be built quickly with legacy DAG-unaware `docker build --target=...`
Expand Down
10 changes: 5 additions & 5 deletions hack/dockerfiles/test.buildkit.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG CONTAINERD10_VERSION=v1.0.3
# available targets: buildkitd, buildkitd.oci_only, buildkitd.containerd_only
ARG BUILDKIT_TARGET=buildkitd
ARG REGISTRY_VERSION=2.6
ARG ROOTLESSKIT_VERSION=d843aadf00d72082fd7a31572ef018d1e792535f
ARG ROOTLESSKIT_VERSION=4f7ae4607d626f0a22fb495056d55b17cce8c01b
ARG ROOTLESS_BASE_MODE=external

# git stage is used for checking out remote repository sources
Expand Down Expand Up @@ -70,8 +70,8 @@ WORKDIR /go/src/github.com/moby/buildkit

# scan the version/revision info
FROM buildkit-base AS buildkit-version
RUN --mount=target=.git,src=.git \
PKG=github.com/moby/buildkit VERSION=$(git describe --match 'v[0-9]*' --dirty='.m' --always) REVISION=$(git rev-parse HEAD)$(if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi); \
RUN --mount=target=. \
PKG=github.com/moby/buildkit VERSION=$(git describe --match 'v[0-9]*' --dirty='.m' --always --tags) REVISION=$(git rev-parse HEAD)$(if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi); \
echo "-X ${PKG}/version.Version=${VERSION} -X ${PKG}/version.Revision=${REVISION} -X ${PKG}/version.Package=${PKG}" | tee /tmp/.ldflags; \
echo -n "${VERSION}" | tee /tmp/.version;

Expand Down Expand Up @@ -204,14 +204,14 @@ COPY --from=binaries / /usr/bin/
COPY . .

FROM alpine AS rootless-base-internal
RUN apk add --no-cache shadow shadow-uidmap \
RUN apk add --no-cache git shadow shadow-uidmap \
&& useradd --create-home --home-dir /home/user --uid 1000 user \
&& mkdir -p /run/user/1000 /home/user/.local/tmp /home/user/.local/share/buildkit \
&& chown -R user /run/user/1000 /home/user \
&& rm /bin/su && ln -s /bin/busybox /bin/su

# tonistiigi/buildkit:rootless-base is a pre-built multi-arch version of rootless-base-internal https://github.com/moby/buildkit/pull/666#pullrequestreview-161872350
FROM tonistiigi/buildkit:rootless-base@sha256:a4999bc477416206973f93046ccfd9d82019f25bbc6400213bb2d27253e13c59 AS rootless-base-external
FROM tonistiigi/buildkit:rootless-base@sha256:6d9c50e2d006c2a8745e9d7f2bc075e4469191eccada41936ec0c6070361d45a AS rootless-base-external
FROM rootless-base-$ROOTLESS_BASE_MODE AS rootless-base

# Rootless mode.
Expand Down
52 changes: 52 additions & 0 deletions hack/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

TAG=$1
REPO=$2
PUSH=$3

set -eu -o pipefail

: ${PLATFORMS=linux/amd64}
: ${CONTINUOUS_INTEGRATION=}

progressFlag=""
if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"; fi


usage() {
echo "usage: ./hack/release <tag> <repo> [push]"
exit 1
}

if [ -z "$TAG" ] || [ -z "$REPO" ]; then
usage
fi

pushFlag=""
if [ "$PUSH" = "push" ]; then
pushFlag="--exporter-opt push=true"
fi

tagLatest=""
tagLatestRootless=""
if [[ "$(git describe --tags --match "v[0-9]*")" == "$TAG" ]]; then
tagLatest=",$REPO:latest"
tagLatestRootless=",$REPO:rootless"
fi

set -x

buildctl build $progressFlag --frontend=dockerfile.v0 \
--local context=. --local dockerfile=. \
--frontend-opt filename=./hack/dockerfiles/test.buildkit.Dockerfile \
--frontend-opt platform=$PLATFORMS \
--exporter image \
--exporter-opt name=$REPO:$TAG$tagLatest $pushFlag

buildctl build $progressFlag --frontend=dockerfile.v0 \
--local context=. --local dockerfile=. \
--frontend-opt target=rootless \
--frontend-opt filename=./hack/dockerfiles/test.buildkit.Dockerfile \
--frontend-opt platform=$PLATFORMS \
--exporter image \
--exporter-opt name=$REPO:$TAG-rootless$tagLatestRootless $pushFlag
33 changes: 33 additions & 0 deletions hack/release-tar
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

TAG=$1
OUT=$2

set -eu -o pipefail

: ${PLATFORMS=linux/amd64}
: ${CONTINUOUS_INTEGRATION=}

progressFlag=""
if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"; fi


usage() {
echo "usage: ./hack/release-tar <tag> <out>"
exit 1
}

if [ -z "$TAG" ] || [ -z "$OUT" ]; then
usage
fi


set -x

buildctl build $progressFlag --frontend=dockerfile.v0 \
--local context=. --local dockerfile=. \
--frontend-opt filename=./hack/dockerfiles/test.buildkit.Dockerfile \
--frontend-opt target=release \
--frontend-opt platform=$PLATFORMS \
--exporter local \
--exporter-opt output=$OUT

0 comments on commit 663f185

Please sign in to comment.