22 Commits

Author SHA1 Message Date
OP (oppenheimer) 576fa63696 Merge pull request #11 from drone-plugins/CI-13848
CI-13848 - Fix "`GLIBC_2.34' not found" in buildah-docker
2024-08-22 23:18:02 +05:30
OP (oppenheimer) 0043db940d Update Dockerfile.linux.amd64 2024-08-22 23:09:31 +05:30
OP (oppenheimer) c99dbd8efa Update Dockerfile.linux.amd64 2024-08-22 22:41:06 +05:30
TP Honey 018dd9ef61 Merge pull request #8 from tphoney/harness_move
(maint) move to harness.drone.io
2022-12-07 14:01:27 +00:00
TP Honey a6e0171dd5 (maint) move to harness.drone.io 2022-12-07 13:58:28 +00:00
TP Honey 8ad8465153 fix docs link 2022-05-31 12:00:36 +01:00
Shubham Agrawal aacad6eca9 Merge pull request #5 from drone-plugins/layer-caching
Support Buildah Layer caching
2021-10-21 23:33:36 +05:30
Jamie Li 3705ed06ac change all dockerfile 2021-10-20 10:47:37 -04:00
Jamie Li 6d4ce8c5ac two stage 2021-10-19 13:20:58 -04:00
Jamie Li 492e84d4b0 fix wrong file 2021-10-19 12:59:17 -04:00
Jamie Li 71af02818a remove git username password 2021-10-19 12:41:00 -04:00
Jamie Li 39f70cdada use single build file 2021-10-18 19:00:14 -04:00
Jamie Li 38f0f1bd3f two stage building 2021-10-18 18:49:57 -04:00
Jamie Li c8b68d31ab use prebuilt binaries 2021-10-12 23:43:34 -04:00
Jamie Li 046362a937 add flags 2021-09-28 23:55:01 -04:00
Jamie Li 566cff614d change dockerfile 2021-09-28 16:53:10 -04:00
Brad Rydzewski cd4f459538 update readme [ci skip] 2021-06-29 18:47:52 -04:00
Brad Rydzewski 494d08375c write auth.json file 2021-06-17 17:22:30 -04:00
Brad Rydzewski 904449e95e Copy login stdout / stderr to console 2021-06-16 15:24:18 -04:00
Shubham Agrawal a8757bdbe0 Merge pull request #3 from drone-plugins/fix_non_docker
fix non-docker registry builds
2021-05-18 17:33:54 +05:30
Shubham Agrawal d645570199 fix drone yml 2021-05-18 17:31:46 +05:30
Shubham Agrawal 2e22a26475 fix non-docker registry builds 2021-05-18 17:30:16 +05:30
10 changed files with 211 additions and 70 deletions
+11 -3
View File
@@ -1,6 +1,12 @@
kind: pipeline
type: docker
name: default
type: vm
platform:
os: linux
arch: amd64
pool:
use: ubuntu
steps:
- name: build
@@ -96,12 +102,14 @@ steps:
---
kind: pipeline
type: docker
type: vm
name: notifications-docker
platform:
os: linux
arch: amd64
pool:
use: ubuntu
steps:
- name: manifest-docker
@@ -166,7 +174,7 @@ steps:
trigger:
ref:
- refs/heads/main
- refs/heads/master
- "refs/tags/**"
depends_on:
+1 -2
View File
@@ -8,7 +8,7 @@
[![Go Doc](https://godoc.org/github.com/drone-plugins/drone-buildah?status.svg)](http://godoc.org/github.com/drone-plugins/drone-buildah)
[![Go Report](https://goreportcard.com/badge/github.com/drone-plugins/drone-buildah)](https://goreportcard.com/report/github.com/drone-plugins/drone-buildah)
Drone plugin uses buildah to build and publish Docker images to a container registry. For the usage information and a listing of the available options please take a look at [the docs](http://plugins.drone.io/drone-plugins/drone-buildah/).
Drone plugin uses buildah to build and publish Docker images to a container registry. For the usage information and a listing of the available options please take a look at [the docs](https://plugins.drone.io/plugins/buildah).
## Build
@@ -66,7 +66,6 @@ docker run --rm \
-e PLUGIN_REPO=octocat/hello-world \
-e DRONE_COMMIT_SHA=d8dbe4d94f15fe89232e0402c6e8a0ddf21af3ab \
--cap-add=SYS_ADMIN \
-v /var/lib/containers/:/var/lib/containers/:Z \
-v $(pwd):$(pwd) \
-w $(pwd) \
plugins/buildah-docker --dry-run
+48
View File
@@ -182,6 +182,46 @@ func main() {
Usage: "additional host:IP mapping",
EnvVar: "PLUGIN_ADD_HOST",
},
cli.StringFlag{
Name: "s3-local-cache-dir",
Usage: "local directory for S3 based cache",
EnvVar: "PLUGIN_S3_LOCAL_CACHE_DIR",
},
cli.StringFlag{
Name: "s3-bucket",
Usage: "S3 bucket name",
EnvVar: "PLUGIN_S3_BUCKET",
},
cli.StringFlag{
Name: "s3-endpoint",
Usage: "S3 endpoint address",
EnvVar: "PLUGIN_S3_ENDPOINT",
},
cli.StringFlag{
Name: "s3-region",
Usage: "S3 region",
EnvVar: "PLUGIN_S3_REGION",
},
cli.StringFlag{
Name: "s3-key",
Usage: "S3 access key",
EnvVar: "PLUGIN_S3_ACCESS_KEY",
},
cli.StringFlag{
Name: "s3-secret",
Usage: "S3 access secret",
EnvVar: "PLUGIN_S3_SECRET",
},
cli.BoolFlag{
Name: "s3-use-ssl",
Usage: "Enable SSL for S3 connections",
EnvVar: "PLUGIN_S3_USE_SSL",
},
cli.BoolFlag{
Name: "layers",
Usage: "User Layers",
EnvVar: "PLUGIN_LAYERS",
},
}
if err := app.Run(os.Args); err != nil {
@@ -221,6 +261,14 @@ func run(c *cli.Context) error {
NoCache: c.Bool("no-cache"),
AddHost: c.StringSlice("add-host"),
Quiet: c.Bool("quiet"),
S3CacheDir: c.String("s3-local-cache-dir"),
S3Bucket: c.String("s3-bucket"),
S3Endpoint: c.String("s3-endpoint"),
S3Region: c.String("s3-region"),
S3Key: c.String("s3-key"),
S3Secret: c.String("s3-secret"),
S3UseSSL: c.Bool("s3-use-ssl"),
Layers: c.Bool("layers"),
},
}
+50 -11
View File
@@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"os/user"
"path/filepath"
"strings"
"time"
@@ -44,6 +45,14 @@ type (
NoCache bool // Docker build no-cache
AddHost []string // Docker build add-host
Quiet bool // Docker build quiet
S3CacheDir string
S3Bucket string
S3Endpoint string
S3Region string
S3Key string
S3Secret string
S3UseSSL bool
Layers bool
}
// Plugin defines the Docker plugin parameters.
@@ -59,23 +68,28 @@ type (
func (p Plugin) Exec() error {
// Create Auth Config File
if p.Login.Config != "" {
homeDir, err := os.UserHomeDir()
user, err := user.Current()
if err != nil {
return fmt.Errorf("failed to find home directory: %s", err)
return fmt.Errorf("Error getting the current user: %s", err)
}
root := fmt.Sprintf("/var/tmp/%s/containers/containers/", user.Uid)
if err := os.MkdirAll(root, 0777); err != nil {
return fmt.Errorf("Error writing runtime dir: %s", err)
}
dockerHome := fmt.Sprintf("%s/.docker/config.json", homeDir)
os.MkdirAll(dockerHome, 0600)
path := filepath.Join(dockerHome, "config.json")
err = ioutil.WriteFile(path, []byte(p.Login.Config), 0600)
if err != nil {
return fmt.Errorf("Error writing config.json: %s", err)
path := filepath.Join(root, "auth.json")
if err := ioutil.WriteFile(path, []byte(p.Login.Config), 0600); err != nil {
return fmt.Errorf("Error writing auth.json: %s", err)
}
fmt.Printf("Config written to %s\n", path)
}
// login to the Docker registry
if p.Login.Password != "" {
cmd := commandLogin(p.Login)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
return fmt.Errorf("Error authenticating: %s", err)
@@ -184,6 +198,7 @@ func commandInfo() *exec.Cmd {
func commandBuild(build Build) *exec.Cmd {
args := []string{
"bud",
"--storage-driver", "vfs",
"-f", build.Dockerfile,
}
@@ -217,6 +232,30 @@ func commandBuild(build Build) *exec.Cmd {
if build.Quiet {
args = append(args, "--quiet")
}
if build.Layers {
args = append(args, "--layers=true")
if build.S3CacheDir != "" {
args = append(args, "--s3-local-cache-dir", build.S3CacheDir)
if build.S3Bucket != "" {
args = append(args, "--s3-bucket", build.S3Bucket)
}
if build.S3Endpoint != "" {
args = append(args, "--s3-endpoint", build.S3Endpoint)
}
if build.S3Region != "" {
args = append(args, "--s3-region", build.S3Region)
}
if build.S3Key != "" {
args = append(args, "--s3-key", build.S3Key)
}
if build.S3Secret != "" {
args = append(args, "--s3-secret", build.S3Secret)
}
if build.S3UseSSL {
args = append(args, "--s3-use-ssl=true")
}
}
}
if build.AutoLabel {
labelSchema := []string{
@@ -297,14 +336,14 @@ func commandTag(build Build, tag string) *exec.Cmd {
target = fmt.Sprintf("%s:%s", build.Repo, tag)
)
return exec.Command(
buildahExe, "tag", source, target,
buildahExe, "tag", "--storage-driver", "vfs", source, target,
)
}
// helper function to create the docker push command.
func commandPush(build Build, tag string) *exec.Cmd {
target := fmt.Sprintf("%s:%s", build.Repo, tag)
return exec.Command(buildahExe, "push", target)
return exec.Command(buildahExe, "push", "--storage-driver", "vfs", target)
}
// helper to check if args match "docker prune"
@@ -318,7 +357,7 @@ func isCommandRmi(args []string) bool {
}
func commandRmi(tag string) *exec.Cmd {
return exec.Command(buildahExe, "rmi", tag)
return exec.Command(buildahExe, "--storage-driver", "vfs", "rmi", tag)
}
// trace writes each command to stdout with the command wrapped in an xml
+1
View File
@@ -18,5 +18,6 @@ USER build
WORKDIR /home/build
# Add plugin binary
ADD release/linux/amd64/drone-docker /bin/
ADD release/linux/amd64/drone-acr /bin/
ENTRYPOINT ["/bin/drone-acr"]
+6 -16
View File
@@ -1,22 +1,12 @@
# Source for dockerfile:
# https://github.com/containers/buildah/blob/master/docs/tutorials/05-openshift-rootless-bud.md
FROM quay.io/buildah/stable:v1.14.8
RUN touch /etc/subgid /etc/subuid \
&& chmod g=u /etc/subgid /etc/subuid /etc/passwd \
&& echo build:10000:65536 > /etc/subuid \
&& echo build:10000:65536 > /etc/subgid
# Use chroot since the default runc does not work when running rootless
RUN echo "export BUILDAH_ISOLATION=chroot" >> /home/build/.bashrc
# Use VFS since fuse does not work
RUN mkdir -p /home/build/.config/containers \
&& echo "driver=\"vfs\"" > /home/build/.config/containers/storage.conf
FROM quay.io/buildah/stable:v1.36.0
# Set up the working directory
USER build
WORKDIR /home/build
RUN export STORAGE_DRIVER=vfs
# Add plugin binary
# Add the plugin binary
ADD release/linux/amd64/drone-docker /bin/
# Set the entrypoint to the plugin binary
ENTRYPOINT ["/bin/drone-docker"]
+31 -12
View File
@@ -1,22 +1,41 @@
# Source for dockerfile:
# https://github.com/containers/buildah/blob/master/docs/tutorials/05-openshift-rootless-bud.md
FROM quay.io/buildah/stable:v1.14.8
FROM fedora
RUN touch /etc/subgid /etc/subuid \
&& chmod g=u /etc/subgid /etc/subuid /etc/passwd \
&& echo build:10000:65536 > /etc/subuid \
&& echo build:10000:65536 > /etc/subgid
RUN dnf -y install \
make \
golang \
bats \
btrfs-progs-devel \
device-mapper-devel \
glib2-devel \
gpgme-devel \
libassuan-devel \
libseccomp-devel \
git \
bzip2 \
go-md2man \
runc \
containers-common \
skopeo-containers
# Use chroot since the default runc does not work when running rootless
RUN echo "export BUILDAH_ISOLATION=chroot" >> /home/build/.bashrc
# Workaround - the first install somehow leaves the golang in a bad state
RUN dnf -y install golang
# Use VFS since fuse does not work
RUN mkdir -p /home/build/.config/containers \
&& echo "driver=\"vfs\"" > /home/build/.config/containers/storage.conf
RUN mkdir /root/buildah && \
cd /root/buildah && \
git clone https://github.com/harness/buildah.git ./src/github.com/containers/buildah
RUN cd /root/buildah/src/github.com/containers/buildah && make && sudo make install
FROM quay.io/buildah/stable:v1.23.0
USER build
WORKDIR /home/build
RUN export STORAGE_DRIVER=vfs
COPY --from=0 /root/buildah/src/github.com/containers/buildah/bin/. /bin/
# Add plugin binary
ADD release/linux/amd64/drone-docker /bin/
ADD release/linux/amd64/drone-ecr /bin/
ENTRYPOINT ["/bin/drone-ecr"]
+31 -12
View File
@@ -1,22 +1,41 @@
# Source for dockerfile:
# https://github.com/containers/buildah/blob/master/docs/tutorials/05-openshift-rootless-bud.md
FROM quay.io/buildah/stable:v1.14.8
FROM fedora
RUN touch /etc/subgid /etc/subuid \
&& chmod g=u /etc/subgid /etc/subuid /etc/passwd \
&& echo build:10000:65536 > /etc/subuid \
&& echo build:10000:65536 > /etc/subgid
RUN dnf -y install \
make \
golang \
bats \
btrfs-progs-devel \
device-mapper-devel \
glib2-devel \
gpgme-devel \
libassuan-devel \
libseccomp-devel \
git \
bzip2 \
go-md2man \
runc \
containers-common \
skopeo-containers
# Use chroot since the default runc does not work when running rootless
RUN echo "export BUILDAH_ISOLATION=chroot" >> /home/build/.bashrc
# Workaround - the first install somehow leaves the golang in a bad state
RUN dnf -y install golang
# Use VFS since fuse does not work
RUN mkdir -p /home/build/.config/containers \
&& echo "driver=\"vfs\"" > /home/build/.config/containers/storage.conf
RUN mkdir /root/buildah && \
cd /root/buildah && \
git clone https://github.com/harness/buildah.git ./src/github.com/containers/buildah
RUN cd /root/buildah/src/github.com/containers/buildah && make && sudo make install
FROM quay.io/buildah/stable:v1.23.0
USER build
WORKDIR /home/build
RUN export STORAGE_DRIVER=vfs
COPY --from=0 /root/buildah/src/github.com/containers/buildah/bin/. /bin/
# Add plugin binary
ADD release/linux/amd64/drone-docker /bin/
ADD release/linux/amd64/drone-gcr /bin/
ENTRYPOINT ["/bin/drone-gcr"]
+31 -12
View File
@@ -1,22 +1,41 @@
# Source for dockerfile:
# https://github.com/containers/buildah/blob/master/docs/tutorials/05-openshift-rootless-bud.md
FROM quay.io/buildah/stable:v1.14.8
FROM fedora
RUN touch /etc/subgid /etc/subuid \
&& chmod g=u /etc/subgid /etc/subuid /etc/passwd \
&& echo build:10000:65536 > /etc/subuid \
&& echo build:10000:65536 > /etc/subgid
RUN dnf -y install \
make \
golang \
bats \
btrfs-progs-devel \
device-mapper-devel \
glib2-devel \
gpgme-devel \
libassuan-devel \
libseccomp-devel \
git \
bzip2 \
go-md2man \
runc \
containers-common \
skopeo-containers
# Use chroot since the default runc does not work when running rootless
RUN echo "export BUILDAH_ISOLATION=chroot" >> /home/build/.bashrc
# Workaround - the first install somehow leaves the golang in a bad state
RUN dnf -y install golang
# Use VFS since fuse does not work
RUN mkdir -p /home/build/.config/containers \
&& echo "driver=\"vfs\"" > /home/build/.config/containers/storage.conf
RUN mkdir /root/buildah && \
cd /root/buildah && \
git clone https://github.com/harness/buildah.git ./src/github.com/containers/buildah
RUN cd /root/buildah/src/github.com/containers/buildah && make && sudo make install
FROM quay.io/buildah/stable:v1.23.0
USER build
WORKDIR /home/build
RUN export STORAGE_DRIVER=vfs
COPY --from=0 /root/buildah/src/github.com/containers/buildah/bin/. /bin/
# Add plugin binary
ADD release/linux/amd64/drone-docker /bin/
ADD release/linux/amd64/drone-heroku /bin/
ENTRYPOINT ["/bin/drone-heroku"]
+1 -2
View File
@@ -14,5 +14,4 @@ GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/drone-gcr ./cmd/drone
GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/drone-ecr ./cmd/drone-ecr
GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/drone-docker ./cmd/drone-docker
GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/drone-acr ./cmd/drone-acr
GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/drone-heroku ./cmd/drone-heroku
GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/drone-heroku ./cmd/drone-heroku