Skip to content

Commit 7a4e5e8

Browse files
committed
chore(builder): use podman replace docker
1 parent 0f35b61 commit 7a4e5e8

12 files changed

Lines changed: 35 additions & 66 deletions

File tree

.woodpecker/build-linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ pipeline:
1313
image: bash
1414
commands:
1515
- export VERSION=$([ -z $CI_COMMIT_TAG ] && echo latest || echo $CI_COMMIT_TAG)-$(sed 's#/#-#g' <<< $CI_SYSTEM_ARCH)
16-
- echo $CONTAINER_PASSWORD | docker login $DRYCC_REGISTRY --username $CONTAINER_USERNAME --password-stdin > /dev/null 2>&1
17-
- make docker-build docker-immutable-push
16+
- echo $CONTAINER_PASSWORD | podman login $DRYCC_REGISTRY --username $CONTAINER_USERNAME --password-stdin > /dev/null 2>&1
17+
- make podman-build podman-immutable-push
1818
secrets:
1919
- codename
2020
- dev_registry

.woodpecker/manifest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ pipeline:
1919
- name: publish-manifest
2020
image: bash
2121
commands:
22-
- docker run --rm
22+
- podman run --rm
2323
-e PLUGIN_SPEC=.woodpecker/manifest.tmpl
2424
-e PLUGIN_USERNAME=$CONTAINER_USERNAME
2525
-e PLUGIN_PASSWORD=$CONTAINER_PASSWORD
2626
-e DRONE_TAG=$CI_COMMIT_TAG
2727
-v $(pwd):$(pwd)
2828
-w $(pwd)
29-
plugins/manifest
29+
docker.io/plugins/manifest
3030
secrets:
3131
- container_username
3232
- container_password

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ RUN groupadd drycc --gid ${DRYCC_GID} \
1919

2020
COPY rootfs/bin /bin/
2121
COPY rootfs/etc/ssh /etc/ssh/
22-
COPY rootfs/docker-entrypoint.sh /docker-entrypoint.sh
22+
COPY rootfs/container-entrypoint.sh /container-entrypoint.sh
2323
COPY --from=build /usr/local/bin/boot /usr/bin/boot
2424

2525
RUN install-packages git openssh-server coreutils xz-utils tar \
2626
&& install-stack mc $MC_VERSION \
2727
&& install-stack jq $JQ_VERSION \
2828
&& mkdir -p /var/run/sshd \
2929
&& rm -rf /etc/ssh/ssh_host* \
30-
&& chmod +x /bin/create_bucket /docker-entrypoint.sh
30+
&& chmod +x /bin/create_bucket /container-entrypoint.sh
3131

3232
USER ${DRYCC_UID}
3333
WORKDIR ${DRYCC_HOME_DIR}
3434

35-
ENTRYPOINT ["init-stack", "/docker-entrypoint.sh"]
35+
ENTRYPOINT ["init-stack", "/container-entrypoint.sh"]
3636
CMD ["/usr/bin/boot", "server"]
3737

3838
EXPOSE 2223

Makefile

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@ SHORT_NAME ?= builder
33
include versioning.mk
44
DRYCC_REGISTRY ?= ${DEV_REGISTRY}
55

6-
# dockerized development environment variables
6+
# container development environment variables
77
REPO_PATH := github.com/drycc/${SHORT_NAME}
88
DEV_ENV_IMAGE := ${DEV_REGISTRY}/drycc/go-dev
99
DEV_ENV_WORK_DIR := /opt/drycc/go/src/${REPO_PATH}
10-
DEV_ENV_PREFIX := docker run --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} --entrypoint testdata/bin/fake-k8s
10+
DEV_ENV_PREFIX := podman run --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} --entrypoint testdata/bin/fake-k8s
1111
DEV_ENV_CMD := ${DEV_ENV_PREFIX} ${DEV_ENV_IMAGE}
1212
PLATFORM ?= linux/amd64,linux/arm64
1313

14-
# SemVer with build information is defined in the SemVer 2 spec, but Docker
14+
# SemVer with build information is defined in the SemVer 2 spec, but podman
1515
# doesn't allow +, so we use -.
1616
BINARY_DEST_DIR := rootfs/usr/bin
1717
# Common flags passed into Go's linker.
1818
LDFLAGS := "-s -w -X main.version=${VERSION}"
19-
# Docker Root FS
19+
# Container Root FS
2020
BINDIR := ./rootfs
2121

2222
bootstrap:
2323
${DEV_ENV_CMD} go mod vendor
2424

25-
# This illustrates a two-stage Docker build. docker-compile runs inside of
26-
# the Docker environment. Other alternatives are cross-compiling, doing
27-
# the build as a `docker build`.
25+
# This illustrates a two-stage Podman build. podman-compile runs inside of
26+
# the container environment. Other alternatives are cross-compiling, doing
27+
# the build as a `podman build`.
2828
build-binary:
2929
CGO_ENABLED=0 go build -ldflags ${LDFLAGS} -o ${BINARY_DEST_DIR}/boot boot.go
3030

@@ -42,20 +42,17 @@ test-unit:
4242
test-cover:
4343
${DEV_ENV_CMD} test-cover.sh
4444

45-
docker-build:
46-
docker build ${DOCKER_BUILD_FLAGS} -t ${IMAGE} --build-arg LDFLAGS=${LDFLAGS} --build-arg CODENAME=${CODENAME} .
47-
docker tag ${IMAGE} ${MUTABLE_IMAGE}
48-
49-
docker-buildx:
50-
docker buildx build --platform ${PLATFORM} -t ${IMAGE} --build-arg LDFLAGS=${LDFLAGS} --build-arg CODENAME=${CODENAME} --push .
45+
podman-build:
46+
podman build -t ${IMAGE} --build-arg LDFLAGS=${LDFLAGS} --build-arg CODENAME=${CODENAME} .
47+
podman tag ${IMAGE} ${MUTABLE_IMAGE}
5148

5249
check-kubectl:
5350
@if [ -z $$(which kubectl) ]; then \
5451
echo "kubectl binary could not be located"; \
5552
exit 2; \
5653
fi
5754

58-
deploy: check-kubectl docker-build docker-push
55+
deploy: check-kubectl podman-build podman-push
5956
kubectl --namespace=drycc patch deployment drycc-$(SHORT_NAME) --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value":"$(IMAGE)"}]'
6057

61-
.PHONY: bootstrap depup build docker-build test test-style test-unit test-cover deploy
58+
.PHONY: bootstrap depup build podman-build test test-style test-unit test-cover deploy

README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,16 @@ The Drycc project welcomes contributions from all developers. The high level pro
4444
* If your PR fixes any [issues][issues], make sure you write `Fixes #1234` in your PR description (where `#1234` is the number of the issue you're closing)
4545
* The Drycc core contributors will review your code. After each of them sign off on your code, they'll label your PR with `LGTM1` and `LGTM2` (respectively). Once that happens, a contributor will merge it
4646

47-
## Docker Based Development Environment
47+
## Container Based Development Environment
4848

49-
The preferred environment for development uses [the `go-dev` Docker image](https://github.com/drycc/docker-go-dev). The tools described in this section are used to build, test, package and release each version of Drycc.
49+
The preferred environment for development uses [the `go-dev` Container image](https://github.com/drycc/go-dev). The tools described in this section are used to build, test, package and release each version of Drycc.
5050

51-
To use it yourself, you must have [make](https://www.gnu.org/software/make/) installed and Docker installed and running on your local development machine.
51+
To use it yourself, you must have [make](https://www.gnu.org/software/make/) installed and Container installed and running on your local development machine.
5252

53-
If you don't have Docker installed, please go to https://www.docker.com/ to install it.
53+
If you don't have Podman installed, please go to https://podman.io/ to install it.
5454

5555
After you have those dependencies, grab Go dependencies with `make bootstrap`, build your code with `make build` and execute unit tests with `make test`.
5656

57-
## Native Go Development Environment
58-
59-
You can also use the standard `go` toolchain to build and test if you prefer. To do so, you'll need [glide](https://github.com/Masterminds/glide) 0.9 or above and [Go 1.6](http://golang.org) or above installed.
60-
61-
After you have those dependencies, you can build and unit-test your code with `go build` and `go test $(glide nv)`, respectively.
62-
63-
Note that you will not be able to build or push Docker images using this method of development.
64-
6557
# Testing
6658

6759
The Drycc project requires that as much code as possible is unit tested, but the core contributors also recognize that some code must be tested at a higher level (functional or integration tests, for example).

charts/builder/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ env:
6363
name: registry-secret
6464
key: host
6565
{{- if eq .Values.global.registryLocation "on-cluster" }}
66-
# NOTE(bacongobbler): use drycc/registry_proxy to work around Docker --insecure-registry requirements
66+
# NOTE(bacongobbler): use drycc/registry_proxy to work around --insecure-registry requirements
6767
- name: "DRYCC_REGISTRY_PROXY_HOST"
6868
value: {{ print "127.0.0.1" ":" .Values.global.registryProxyPort }}
6969
{{- else }}

pkg/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Package pkg provides common libraries for the Drycc builder.
22
//
3-
// The Drycc builder is responsible for building buildpack and docker images for use in the Drycc
3+
// The Drycc builder is responsible for building buildpack and container images for use in the Drycc
44
// on the Drycc PaaS platform.
55
package pkg
66

pkg/gitreceive/k8s_util.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package gitreceive
22

33
import (
44
"context"
5-
"encoding/json"
65
"fmt"
76
"os"
87
"strconv"
@@ -54,18 +53,6 @@ func createBuilderJob(
5453
) *batchv1.Job {
5554

5655
job := buildJob(debug, name, namespace, pullPolicy, securityContext, nodeSelector, env)
57-
58-
// inject application envvars as a special envvar which will be handled by imagebuilder to
59-
// inject them as build-time variables.
60-
// NOTE(bacongobbler): image-py takes buildargs as a json string in the form of
61-
//
62-
// {"KEY": "value"}
63-
//
64-
// So we need to translate the map into json.
65-
if _, ok := env["DRYCC_DOCKER_BUILD_ARGS_ENABLED"]; ok {
66-
imageBuildArgs, _ := json.Marshal(env)
67-
addEnvToJob(job, "DOCKER_BUILD_ARGS", string(imageBuildArgs))
68-
}
6956
job.Spec.Template.Spec.Containers[0].Name = builderName
7057
job.Spec.Template.Spec.Containers[0].Image = builderImage
7158

pkg/gitreceive/k8s_util_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ func TestBuildJob(t *testing.T) {
4747

4848
env := make(map[string]interface{})
4949
env["KEY"] = "VALUE"
50-
buildArgsEnv := make(map[string]interface{})
51-
buildArgsEnv["DRYCC_DOCKER_BUILD_ARGS_ENABLED"] = "1"
52-
buildArgsEnv["KEY"] = "VALUE"
5350
var job *batchv1.Job
5451

5552
emptyNodeSelector := make(map[string]string)
@@ -69,7 +66,6 @@ func TestBuildJob(t *testing.T) {
6966
{true, "test", "default", env, "tar", "deadbeef", "img", "imagebuilder", "customimage", corev1.PullAlways, emptyNodeSelector},
7067
{true, "test", "default", env, "tar", "deadbeef", "img", "imagebuilder", "customimage", corev1.PullIfNotPresent, emptyNodeSelector},
7168
{true, "test", "default", env, "tar", "deadbeef", "img", "imagebuilder", "customimage", corev1.PullNever, nil},
72-
{true, "test", "default", buildArgsEnv, "tar", "deadbeef", "img", "imagebuilder", "customimage", corev1.PullIfNotPresent, emptyNodeSelector},
7369
}
7470
buildImageEnv := map[string]string{"DRYCC_REGISTRY_LOCATION": "on-cluster"}
7571
for _, build := range imageBuilds {
@@ -100,9 +96,6 @@ func TestBuildJob(t *testing.T) {
10096
checkForEnv(t, job, "TAR_PATH", build.tarKey)
10197
checkForEnv(t, job, "IMAGE_NAME", build.imgName)
10298
checkForEnv(t, job, "DRYCC_REGISTRY_LOCATION", "on-cluster")
103-
if _, ok := build.env["DRYCC_DOCKER_BUILD_ARGS_ENABLED"]; ok {
104-
checkForEnv(t, job, "DOCKER_BUILD_ARGS", `{"DRYCC_DOCKER_BUILD_ARGS_ENABLED":"1","KEY":"VALUE"}`)
105-
}
10699
if build.imagebuilderImage != "" {
107100
if job.Spec.Template.Spec.Containers[0].Image != build.imagebuilderImage {
108101
t.Errorf("expected %v but returned %v", build.imagebuilderImage, job.Spec.Template.Spec.Containers[0].Image)

rootfs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# RootFS
22

33
This directory stores all files that should be copied to the rootfs of a
4-
Docker container. The files should be stored according to the correct
5-
directory structure of the destination container. For example:
4+
container. The files should be stored according to the correct directory
5+
structure of the destination container. For example:
66

77
```
88
rootfs/bin -> /bin

0 commit comments

Comments
 (0)