ci: Makefile / Dockerfile cleanup
This commit is contained in:
parent
f47cefbd36
commit
1d410bc1f0
21
Dockerfile
21
Dockerfile
@ -1,6 +1,6 @@
|
|||||||
ARG RUNTIME_VERSION="3.10"
|
ARG RUNTIME_VERSION="3.10"
|
||||||
ARG DISTRO_VERSION="3.16"
|
ARG DISTRO_VERSION="3.16"
|
||||||
ARG PULUMI_VERSION="3.35.3"
|
ARG PULUMI_VERSION="3.36.0"
|
||||||
|
|
||||||
FROM python:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} AS builder
|
FROM python:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} AS builder
|
||||||
ARG PULUMI_VERSION
|
ARG PULUMI_VERSION
|
||||||
@ -36,7 +36,7 @@ RUN pip install -r requirements.txt
|
|||||||
RUN pip install . --no-deps
|
RUN pip install . --no-deps
|
||||||
|
|
||||||
# minimal pulumi
|
# minimal pulumi
|
||||||
RUN cd /root/.pulumi/bin && rm -f *dotnet *nodejs *go *java && strip pulumi* || true
|
RUN cd /root/.pulumi/bin && rm -f *dotnet *yaml *go *java && strip pulumi* || true
|
||||||
|
|
||||||
|
|
||||||
# Now build the final runtime, incl. running rootless containers
|
# Now build the final runtime, incl. running rootless containers
|
||||||
@ -68,19 +68,14 @@ RUN addgroup $USER && adduser $USER -G $USER -D && \
|
|||||||
chown $USER:$USER -R /home/$USER
|
chown $USER:$USER -R /home/$USER
|
||||||
|
|
||||||
# Rootless podman
|
# Rootless podman
|
||||||
# https://github.com/containers/podman/blob/main/contrib/podmanimage/stable/Containerfile
|
RUN mkdir -p /home/$USER/.config/containers
|
||||||
ADD conf/containers.conf conf/registries.conf conf/storage.conf /etc/containers/
|
|
||||||
ADD --chown=$USER:$USER conf/podman-containers.conf /home/$USER/.config/containers/containers.conf
|
|
||||||
|
|
||||||
RUN mkdir -p /var/lib/shared/overlay-images /var/lib/shared/overlay-layers \
|
ADD --chown=$USER:$USER conf/containers.conf conf/registries.conf conf/storage.conf /home/$USER/.config/containers
|
||||||
/var/lib/shared/vfs-images /var/lib/shared/vfs-layers && \
|
|
||||||
touch /var/lib/shared/overlay-images/images.lock /var/lib/shared/overlay-layers/layers.lock \
|
RUN echo -e "$USER:1:999\n$USER:1001:64535" > /etc/subuid && \
|
||||||
/var/lib/shared/vfs-images/images.lock /var/lib/shared/vfs-layers/layers.lock && \
|
|
||||||
mkdir /tmp/podman-run-1000 && chown $USER:$USER /tmp/podman-run-1000 && chmod 700 /tmp/podman-run-1000 && \
|
|
||||||
echo -e "$USER:1:999\n$USER:1001:64535" > /etc/subuid && \
|
|
||||||
echo -e "$USER:1:999\n$USER:1001:64535" > /etc/subgid && \
|
echo -e "$USER:1:999\n$USER:1001:64535" > /etc/subgid && \
|
||||||
mkdir /workspace && \
|
cd /usr/bin && ln -s podman docker && \
|
||||||
cd /usr/bin && ln -s podman docker
|
chown $USER:$USER -R /home/$USER
|
||||||
|
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
|
|
||||||
|
42
Makefile
42
Makefile
@ -1,29 +1,27 @@
|
|||||||
REGISTRY := public.ecr.aws/zero-downtime
|
REGISTRY := public.ecr.aws/zero-downtime
|
||||||
REPOSITORY := cloudbender
|
IMAGE := cloudbender
|
||||||
REGION := us-east-1
|
REGION := us-east-1
|
||||||
|
|
||||||
# Parse version from latest git semver tag
|
# Parse version from latest git semver tag
|
||||||
GTAG=$(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
|
GTAG=$(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
|
||||||
TAG ?= $(shell echo $(GTAG) | awk -F '-' '{ print $$1 "-" $$2 }' | sed -e 's/-$$//')
|
TAG ?= $(shell echo $(GTAG) | awk -F '-' '{ print $$1 "-" $$2 }' | sed -e 's/-$$//')
|
||||||
|
|
||||||
ifeq ($(TRIVY_REMOTE),)
|
ifneq ($(TRIVY_REMOTE),)
|
||||||
TRIVY_OPTS := image
|
TRIVY_OPTS := --server ${TRIVY_REMOTE}
|
||||||
else
|
|
||||||
TRIVY_OPTS := client --remote ${TRIVY_REMOTE}
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: pytest build test_upload upload all dev_setup pybuild
|
.PHONY: test build test_upload upload all docker_build docker_test docker_push docker_scan
|
||||||
|
|
||||||
all: pytest pybuild
|
all: test build
|
||||||
|
|
||||||
pytest:
|
test:
|
||||||
flake8 cloudbender tests
|
flake8 cloudbender tests
|
||||||
TEST=True pytest --log-cli-level=DEBUG
|
TEST=True pytest --log-cli-level=DEBUG
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf .cache build .coverage .eggs cloudbender.egg-info .pytest_cache dist
|
rm -rf .cache build .coverage .eggs cloudbender.egg-info .pytest_cache dist
|
||||||
|
|
||||||
pybuild:
|
build:
|
||||||
hatchling build
|
hatchling build
|
||||||
|
|
||||||
test_upload: pybuild
|
test_upload: pybuild
|
||||||
@ -32,19 +30,23 @@ test_upload: pybuild
|
|||||||
upload: pybuild
|
upload: pybuild
|
||||||
twine upload -r pypi --non-interactive dist/cloudbender-*.whl
|
twine upload -r pypi --non-interactive dist/cloudbender-*.whl
|
||||||
|
|
||||||
build:
|
docker_build:
|
||||||
podman build --rm -t $(REPOSITORY):$(TAG) -t $(REPOSITORY):latest .
|
podman build --rm -t $(IMAGE):$(TAG) -t $(IMAGE):latest .
|
||||||
|
|
||||||
test:
|
docker_test:
|
||||||
@echo "Not implemented (yet)"
|
@echo "Not implemented (yet)"
|
||||||
|
|
||||||
push:
|
docker_push:
|
||||||
aws ecr-public get-login-password --region $(REGION) | podman login --username AWS --password-stdin $(REGISTRY)
|
aws ecr-public get-login-password --region $(REGION) | podman login --username AWS --password-stdin $(REGISTRY)
|
||||||
podman tag $(REPOSITORY):latest $(REGISTRY)/$(REPOSITORY):$(TAG) $(REGISTRY)/$(REPOSITORY):latest
|
podman tag $(IMAGE):latest $(REGISTRY)/$(IMAGE):$(TAG) $(REGISTRY)/$(IMAGE):latest
|
||||||
podman push $(REGISTRY)/$(REPOSITORY):$(TAG)
|
podman push $(REGISTRY)/$(IMAGE):$(TAG)
|
||||||
podman push $(REGISTRY)/$(REPOSITORY):latest
|
podman push $(REGISTRY)/$(IMAGE):latest
|
||||||
# Delete all untagged images
|
|
||||||
# aws ecr-public batch-delete-image --repository-name $(REPOSITORY) --region $(REGION) --image-ids $$(for image in $$(aws ecr-public describe-images --repository-name $(REPOSITORY) --region $(REGION) --output json | jq -r '.imageDetails[] | select(.imageTags | not ).imageDigest'); do echo -n "imageDigest=$$image "; done)
|
|
||||||
|
|
||||||
scan:
|
docker_scan:
|
||||||
trivy $(TRIVY_OPTS) $(REPOSITORY):$(TAG)
|
trivy image $(TRIVY_OPTS) $(IMAGE):$(TAG)
|
||||||
|
|
||||||
|
# Delete all untagged images
|
||||||
|
.PHONY: rm-remote-untagged
|
||||||
|
rm-remote-untagged:
|
||||||
|
@echo "Removing all untagged images from $(IMAGE) in $(REGION)"
|
||||||
|
@aws ecr-public batch-delete-image --repository-name $(IMAGE) --region $(REGION) --image-ids $$(for image in $$(aws ecr-public describe-images --repository-name $(IMAGE) --region $(REGION) --output json | jq -r '.imageDetails[] | select(.imageTags | not ).imageDigest'); do echo -n "imageDigest=$$image "; done)
|
||||||
|
Loading…
Reference in New Issue
Block a user