Compare commits

...

2 commits

Author SHA1 Message Date
Felix Bartels 2f413b92b1 Add separate stage to build a distrobox optimized container
Signed-off-by: Felix Bartels <felix@9wd.eu>
2023-08-06 17:54:37 +02:00
Felix Bartels 0ac667af18 Update surfer to 6.0
This also updates the gear and adds an optional bash script instead of
the Makefile

Signed-off-by: Felix Bartels <felix@9wd.eu>
2023-08-06 14:34:08 +02:00
3 changed files with 81 additions and 8 deletions

View file

@ -1,4 +1,41 @@
FROM node:lts-alpine3.12
RUN apk add --no-cache make python3 zip
FROM node:lts as build
# use --unsafe to not execute post actions as user nobody
RUN npm -g install cloudron-surfer@5.17.5 --unsafe && npm cache clean --force && surfer --version
RUN npm -g install cloudron-surfer@6.0.0 --unsafe && \
npm cache clean --force && \
surfer --version
FROM build as distrobox
# Install essential packages and locales
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
bash \
bash-completion \
bc \
curl \
dialog \
diffutils \
findutils \
gnupg2 \
less \
libegl1-mesa \
libgl1-mesa-glx \
libnss-myhostname \
libvte-2.9*-common \
libvte-common \
libvulkan1 \
locales \
lsof \
mesa-vulkan-drivers \
ncurses-base \
passwd \
pinentry-curses \
procps \
sudo \
time \
tzdata \
util-linux \
wget
# make sure that the distrobox stage is not the last one
FROM build as surfer

View file

@ -2,20 +2,26 @@ DOCKER_REPO ?= fbartels
DOCKER_IMAGE := cloudron-surfer
VERSION := $(shell grep cloudron-surfer Dockerfile | cut -d' ' -f 5 | cut -d@ -f 2)
ifeq ($(shell command -v podman 2> /dev/null),)
CMD=docker
else
CMD=podman
endif
.PHONY: default
default: build
.PHONY: build
build:
docker build . -t $(DOCKER_IMAGE)
$(CMD) build . -t $(DOCKER_IMAGE)
.PHONY: tag
tag: build
docker tag $(DOCKER_IMAGE) $(DOCKER_REPO)/$(DOCKER_IMAGE):latest
docker tag $(DOCKER_IMAGE) $(DOCKER_REPO)/$(DOCKER_IMAGE):$(VERSION)
$(CMD) tag $(DOCKER_IMAGE) $(DOCKER_REPO)/$(DOCKER_IMAGE):latest
$(CMD) tag $(DOCKER_IMAGE) $(DOCKER_REPO)/$(DOCKER_IMAGE):$(VERSION)
.PHONY: push
push: tag
docker push $(DOCKER_REPO)/$(DOCKER_IMAGE):latest
docker push $(DOCKER_REPO)/$(DOCKER_IMAGE):$(VERSION)
$(CMD) push $(DOCKER_REPO)/$(DOCKER_IMAGE):latest
$(CMD) push $(DOCKER_REPO)/$(DOCKER_IMAGE):$(VERSION)

30
helpers/surfer/build.sh Executable file
View file

@ -0,0 +1,30 @@
#!/bin/bash
set -Eeuo pipefail
DOCKER_IMAGE=${DOCKER_IMAGE:-git.9wd.eu/felix/cloudron-surfer}
VERSION=$(grep cloudron-surfer Dockerfile | cut -d' ' -f 5 | cut -d@ -f 2)
# Function to check if a command is available
command_exists() {
command -v "$1" >/dev/null 2>&1
}
if command_exists podman; then
CMD="podman"
elif command_exists docker; then
CMD="docker"
else
echo "Error: Neither podman nor docker is installed."
exit 1
fi
$CMD build . -t "$DOCKER_IMAGE:latest"
$CMD build . --target distrobox -t "$DOCKER_IMAGE:distrobox"
$CMD tag "$DOCKER_IMAGE:latest" "$DOCKER_IMAGE:$VERSION"
if [ "${1:-}" == "push" ]; then
$CMD push "$DOCKER_IMAGE:latest"
$CMD push "$DOCKER_IMAGE:$VERSION"
$CMD push "$DOCKER_IMAGE:distrobox"
fi