Skip to content

Commit c28ef6b

Browse files
committed
chore(imagebuilder): use podman replace docker
1 parent 0e5181e commit c28ef6b

8 files changed

Lines changed: 99 additions & 43 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

Makefile

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,22 @@ SHELL_SCRIPTS = $(wildcard _scripts/*.sh) \
1616
# and other build options
1717
DEV_ENV_IMAGE := ${DEV_REGISTRY}/drycc/go-dev
1818
DEV_ENV_WORK_DIR := /opt/drycc/go/src/${REPO_PATH}
19-
DEV_ENV_CMD := docker run --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${DEV_ENV_IMAGE}
20-
DEV_ENV_CMD_INT := docker run -it --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${DEV_ENV_IMAGE}
19+
DEV_ENV_CMD := podman run --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${DEV_ENV_IMAGE}
20+
DEV_ENV_CMD_INT := podman run -it --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${DEV_ENV_IMAGE}
2121

22-
all: build docker-build docker-push
22+
all: build podman-build podman-push
2323

2424
bootstrap:
2525
@echo Nothing to do.
2626

2727
build:
2828
@echo Nothing to do.
2929

30-
docker-build:
31-
docker build ${DOCKER_BUILD_FLAGS} --build-arg CODENAME=${CODENAME} -t ${IMAGE} -f rootfs/Dockerfile rootfs
32-
docker tag ${IMAGE} ${MUTABLE_IMAGE}
30+
podman-build:
31+
podman build ${CONTAINER_BUILD_FLAGS} --build-arg CODENAME=${CODENAME} -t ${IMAGE} -f rootfs/Dockerfile rootfs
32+
podman tag ${IMAGE} ${MUTABLE_IMAGE}
3333

34-
docker-buildx:
35-
docker buildx build --build-arg CODENAME=${CODENAME} --platform ${PLATFORM} ${DOCKER_BUILD_FLAGS} -t ${IMAGE} -f rootfs/Dockerfile rootfs --push
36-
37-
deploy: docker-build docker-push
34+
deploy: podman-build podman-push
3835

3936
kube-pod: kube-service
4037
kubectl create -f ${POD}
@@ -61,5 +58,5 @@ test-style:
6158
test-functional:
6259
@echo "Implement functional tests in _tests directory"
6360

64-
.PHONY: all bootstrap build docker-build docker-push deploy kube-pod kube-secrets \
61+
.PHONY: all bootstrap build podman-build podman-push deploy kube-pod kube-secrets \
6562
secrets kube-service kube-clean test
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: imagebuilder-networkpolicy
5+
spec:
6+
podSelector:
7+
matchLabels:
8+
app: drycc-imagebuilder
9+
policyTypes:
10+
- Egress
11+
egress:
12+
- to:
13+
- namespaceSelector:
14+
matchLabels:
15+
kubernetes.io/metadata.name: kube-system
16+
- podSelector:
17+
matchLabels:
18+
k8s-app: kube-dns
19+
ports:
20+
- protocol: UDP
21+
port: 53
22+
- to:
23+
- ipBlock:
24+
cidr: ::/0
25+
except:
26+
- fc00::/7
27+
- to:
28+
- ipBlock:
29+
cidr: 0.0.0.0/0
30+
except:
31+
- 10.0.0.0/8
32+
- 172.16.0.0/12
33+
- 192.168.0.0/16
34+
- to:
35+
- namespaceSelector:
36+
matchLabels:
37+
kubernetes.io/metadata.name: {{ .Release.Name }}
38+
- podSelector:
39+
matchLabels:
40+
app: drycc-registry
41+
ports:
42+
- protocol: TCP
43+
port: 5000
44+
- to:
45+
- namespaceSelector:
46+
matchLabels:
47+
kubernetes.io/metadata.name: {{ .Release.Name }}
48+
- podSelector:
49+
matchLabels:
50+
app: drycc-storage-metanode-weed
51+
ports:
52+
- protocol: TCP
53+
port: 8333

charts/imagebuilder/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ imageRegistry: "registry.drycc.cc"
55
codename: bookworm
66
containerRegistries: |
77
unqualified-search-registries = ["registry.drycc.cc"]
8-
short-name-mode="permissive"
8+
short-name-mode="permissive"

rootfs/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ FROM registry.drycc.cc/drycc/base:${CODENAME}
44
ENV DRYCC_UID=1001 \
55
DRYCC_GID=1001 \
66
DRYCC_HOME_DIR=/home/drycc \
7-
PODMAN_VERSION="4.6.0" \
8-
MC_VERSION="2023.07.21.20.44.27" \
7+
PODMAN_VERSION="4.7.1" \
8+
MC_VERSION="2023.09.20.15.22.31" \
99
CADDY_VERSION="2.7.1" \
10-
PACK_VERSION="0.29.0" \
10+
PACK_VERSION="0.31.0" \
1111
GOSU_VERSION="1.16"
1212

1313
RUN groupadd drycc --gid ${DRYCC_GID} \
@@ -41,4 +41,3 @@ RUN install-packages procps psmisc \
4141
WORKDIR /workspace
4242

4343
ENTRYPOINT ["init-stack", "/imagebuilder/prebuild", "/imagebuilder/build"]
44-

rootfs/imagebuilder/build

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/usr/bin/env bash
22
set -eo pipefail
33
shopt -s expand_aliases
4-
alias podman="podman --cgroup-manager=cgroupfs --events-backend=file"
4+
5+
log_level="error"
6+
if [[ "${DRYCC_DEBUG}" ]]; then
7+
log_level="debug"
8+
unset DRYCC_DEBUG
9+
fi
10+
11+
alias podman='podman --log-level ${log_level} --cgroup-manager=cgroupfs --events-backend=file'
512

613
function clean_before_exit {
714
# delay before exiting, so stdout/stderr flushes through the logging system
@@ -29,12 +36,6 @@ function waiting_process {
2936
done
3037
}
3138

32-
log_level="error"
33-
if [[ "${DRYCC_DEBUG}" ]]; then
34-
log_level="debug"
35-
unset DRYCC_DEBUG
36-
fi
37-
3839
CONTAINERS_CONFIG_DIR="${HOME}"/.config/containers
3940
mkdir -p "${CONTAINERS_CONFIG_DIR}"
4041
from_registries_file="/etc/imagebuilder/registries.conf"
@@ -43,6 +44,8 @@ if [ -f "${from_registries_file}" ]; then
4344
install -D "${from_registries_file}" "${CONTAINERS_CONFIG_DIR}"/registries.conf
4445
fi
4546

47+
# The directory cannot be changed, the position is hard coded, pack cli needs to be used.
48+
# https://github.com/buildpacks/pack/blob/main/internal/docker/context.go
4649
REGISTRY_AUTH_FILE="${HOME}"/.docker/config.json
4750
readonly REGISTRY_AUTH_FILE
4851
from_auths_file="/etc/imagebuilder/auths.json"
@@ -100,23 +103,27 @@ image_latest_name="${image_base_name}":latest
100103
# Building
101104
if [[ "${DRYCC_STACK}" == "container" ]] ; then
102105
echo "---> Building container"
103-
if [[ $log_level == "debug" ]] ; then
104-
podman build --tag"${IMAGE_NAME}" --network host .
105-
podman push "${IMAGE_NAME}" --tls-verify=false
106-
else
107-
podman build --quiet --tag "${IMAGE_NAME}" --network host .
108-
podman push "${IMAGE_NAME}" --quiet --tls-verify=false
106+
podman_build="podman build . --tag ${IMAGE_NAME} --network host"
107+
podman_push="podman push ${IMAGE_NAME} --tls-verify=false"
108+
if [[ -f .build-env ]] ; then
109+
for build_arg in $( < .build-env )
110+
do
111+
podman_build="$podman_build --build-arg $build_arg"
112+
done
109113
fi
114+
$podman_build
115+
$podman_push
110116
else
111117
echo "---> Building pack"
112118
echo "---> Using builder ${pack_builder}"
113119
# podman connection
114-
DOCKER_HOST="unix://$(podman info -f "{{.Host.RemoteSocket.Path}}")"
120+
DOCKER_HOST="unix://$(podman info -f '{{.Host.RemoteSocket.Path}}')"
115121
readonly DOCKER_HOST
116122
export DOCKER_HOST
117123

118124
pack_build="pack build ${IMAGE_NAME} \
119125
--builder ${pack_builder} \
126+
--lifecycle-image ${pack_builder} \
120127
--env DRYCC_APP=${drycc_app} \
121128
--docker-host ${DOCKER_HOST} \
122129
--previous-image ${image_latest_name} \

versioning.mk

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MUTABLE_VERSION ?= canary
22
VERSION ?= git-$(shell git rev-parse --short HEAD)
3-
DOCKER_BUILD_FLAGS ?= --pull
3+
CONTAINER_BUILD_FLAGS ?= --pull
44

55
IMAGE := ${DRYCC_REGISTRY}/${IMAGE_PREFIX}/${SHORT_NAME}:${VERSION}
66
MUTABLE_IMAGE := ${DRYCC_REGISTRY}/${IMAGE_PREFIX}/${SHORT_NAME}:${MUTABLE_VERSION}
@@ -11,13 +11,13 @@ info:
1111
@echo "Immutable tag: ${IMAGE}"
1212
@echo "Mutable tag: ${MUTABLE_IMAGE}"
1313

14-
.PHONY: docker-push
15-
docker-push: docker-immutable-push docker-mutable-push
14+
.PHONY: podman-push
15+
podman-push: podman-immutable-push podman-mutable-push
1616

17-
.PHONY: docker-immutable-push
18-
docker-immutable-push:
19-
docker push ${IMAGE}
17+
.PHONY: podman-immutable-push
18+
podman-immutable-push:
19+
podman push ${IMAGE}
2020

21-
.PHONY: docker-mutable-push
22-
docker-mutable-push:
23-
docker push ${MUTABLE_IMAGE}
21+
.PHONY: podman-mutable-push
22+
podman-mutable-push:
23+
podman push ${MUTABLE_IMAGE}

0 commit comments

Comments
 (0)