diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 93f3780..6b0be57 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1 @@ -# These are supported funding model platforms - -custom: https://www.paypal.me/hectormf +custom: https://hector.molinero.dev/donate diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 018ca69..83f3181 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,38 +1,38 @@ -image: docker:stable +image: "docker.io/docker:stable" services: - - docker:dind + - "docker:dind" stages: - - build:images - - push:images + - "build:images" + - "push:images" variables: - DOCKER_HOST: tcp://docker:2375 - DOCKER_DRIVER: overlay2 + DOCKER_HOST: "tcp://docker:2375" + DOCKER_DRIVER: "overlay2" build:image: - stage: build:images + stage: "build:images" before_script: - - docker info - - apk add --no-cache coreutils git make xz + - "docker info" + - "apk add --no-cache coreutils git make xz" script: - - make build-image save-image + - "make build-image save-image" artifacts: - expire_in: 1 hour + expire_in: "1 hour" paths: - - dist/ + - "dist/" push:image: - stage: push:images + stage: "push:images" before_script: - - apk add --no-cache coreutils git make xz - - docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}" >/dev/null 2>&1 + - "apk add --no-cache coreutils git make xz" + - "docker login -u \"${CI_REGISTRY_USER:?}\" -p \"${CI_REGISTRY_PASSWORD:?}\" \"${CI_REGISTRY:?}\" >/dev/null 2>&1" script: - - make load-image push-image + - "make load-image push-image" only: - - /^v([0-9.]+)(-.+)?$/ + - "/^v([0-9.]+)(-.+)?$/" except: - - branches + - "branches" dependencies: - - build:image + - "build:image" diff --git a/Dockerfile b/Dockerfile index d064a63..7c6089d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,8 +35,8 @@ RUN mkdir -p /var/lib/qemu/images/ /var/lib/qemu/iso/ ARG REACTOS_ISO_URL=https://downloads.sourceforge.net/project/reactos/ReactOS/0.4.11/ReactOS-0.4.11-iso.zip ARG REACTOS_ISO_CHECKSUM=68120b3481c99c6b0563d5f3ec469ab197f2c8abc38d29adba4c40d01acd92c8 RUN mkdir /tmp/reactos/ \ - && curl -Lo /tmp/reactos/reactos.zip "${REACTOS_ISO_URL}" \ - && echo "${REACTOS_ISO_CHECKSUM} /tmp/reactos/reactos.zip" | sha256sum -c \ + && curl -Lo /tmp/reactos/reactos.zip "${REACTOS_ISO_URL:?}" \ + && echo "${REACTOS_ISO_CHECKSUM:?} /tmp/reactos/reactos.zip" | sha256sum -c \ && unzip /tmp/reactos/reactos.zip -d /tmp/reactos/ \ && mv /tmp/reactos/*.iso /var/lib/qemu/iso/reactos.iso \ && rm -rf /tmp/reactos/ @@ -53,4 +53,4 @@ EXPOSE 5900/tcp ## noVNC EXPOSE 6080/tcp -CMD ["/usr/local/bin/docker-foreground-cmd"] +CMD ["/usr/local/bin/container-foreground-cmd"] diff --git a/Makefile b/Makefile index 6f7b3fb..ac6ee8e 100644 --- a/Makefile +++ b/Makefile @@ -93,9 +93,9 @@ push-image: version: @if printf -- '%s' '$(IMAGE_VERSION)' | grep -q '^v[0-9]\{1,\}$$'; then \ NEW_IMAGE_VERSION=$$(awk -v 'v=$(IMAGE_VERSION)' 'BEGIN {printf "v%.0f", substr(v,2)+1}'); \ - printf -- '%s\n' "$${NEW_IMAGE_VERSION}" > ./VERSION; \ - '$(GIT)' add ./VERSION; '$(GIT)' commit -m "$${NEW_IMAGE_VERSION}"; \ - '$(GIT)' tag -a "$${NEW_IMAGE_VERSION}" -m "$${NEW_IMAGE_VERSION}"; \ + printf -- '%s\n' "$${NEW_IMAGE_VERSION:?}" > '$(VERSION_FILE)'; \ + '$(GIT)' add '$(VERSION_FILE)'; '$(GIT)' commit -m "$${NEW_IMAGE_VERSION:?}"; \ + '$(GIT)' tag -a "$${NEW_IMAGE_VERSION:?}" -m "$${NEW_IMAGE_VERSION:?}"; \ else \ >&2 printf -- 'Malformed version string: %s\n' '$(IMAGE_VERSION)'; \ exit 1; \ diff --git a/run.sh b/run.sh index 33ccac4..600701b 100755 --- a/run.sh +++ b/run.sh @@ -3,42 +3,45 @@ set -eu export LC_ALL=C +DOCKER=$(command -v docker 2>/dev/null) + +IMAGE_REGISTRY=docker.io IMAGE_NAMESPACE=hectormolinero IMAGE_PROJECT=qemu-reactos IMAGE_TAG=latest -IMAGE_NAME=${IMAGE_NAMESPACE}/${IMAGE_PROJECT}:${IMAGE_TAG} -CONTAINER_NAME=${IMAGE_PROJECT} +IMAGE_NAME=${IMAGE_REGISTRY:?}/${IMAGE_NAMESPACE:?}/${IMAGE_PROJECT:?}:${IMAGE_TAG:?} +CONTAINER_NAME=${IMAGE_PROJECT:?} -imageExists() { [ -n "$(docker images -q "$1")" ]; } -containerExists() { docker ps -aqf name="$1" --format '{{.Names}}' | grep -Fxq "$1"; } -containerIsRunning() { docker ps -qf name="$1" --format '{{.Names}}' | grep -Fxq "$1"; } +imageExists() { [ -n "$("${DOCKER:?}" images -q "${1:?}")" ]; } +containerExists() { "${DOCKER:?}" ps -af name="${1:?}" --format '{{.Names}}' | grep -Fxq "${1:?}"; } +containerIsRunning() { "${DOCKER:?}" ps -f name="${1:?}" --format '{{.Names}}' | grep -Fxq "${1:?}"; } -if ! imageExists "${IMAGE_NAME}"; then - >&2 printf -- '%s\n' "\"${IMAGE_NAME}\" image doesn't exist!" +if ! imageExists "${IMAGE_NAME:?}" && ! imageExists "${IMAGE_NAME#docker.io/}"; then + >&2 printf -- '%s\n' "\"${IMAGE_NAME:?}\" image doesn't exist!" exit 1 fi -if containerIsRunning "${CONTAINER_NAME}"; then - printf -- '%s\n' "Stopping \"${CONTAINER_NAME}\" container..." - docker stop "${CONTAINER_NAME}" >/dev/null +if containerIsRunning "${CONTAINER_NAME:?}"; then + printf -- '%s\n' "Stopping \"${CONTAINER_NAME:?}\" container..." + "${DOCKER:?}" stop "${CONTAINER_NAME:?}" >/dev/null fi -if containerExists "${CONTAINER_NAME}"; then - printf -- '%s\n' "Removing \"${CONTAINER_NAME}\" container..." - docker rm "${CONTAINER_NAME}" >/dev/null +if containerExists "${CONTAINER_NAME:?}"; then + printf -- '%s\n' "Removing \"${CONTAINER_NAME:?}\" container..." + "${DOCKER:?}" rm "${CONTAINER_NAME:?}" >/dev/null fi -printf -- '%s\n' "Creating \"${CONTAINER_NAME}\" container..." -docker run --detach \ - --name "${CONTAINER_NAME}" \ - --hostname "${CONTAINER_NAME}" \ +printf -- '%s\n' "Creating \"${CONTAINER_NAME:?}\" container..." +"${DOCKER:?}" run --detach \ + --name "${CONTAINER_NAME:?}" \ + --hostname "${CONTAINER_NAME:?}" \ --restart on-failure:3 \ --log-opt max-size=32m \ --publish '127.0.0.1:5900:5900/tcp' \ --publish '127.0.0.1:6080:6080/tcp' \ --publish '127.0.0.1:15900:15900/tcp' \ --privileged --env QEMU_KVM=true \ - "${IMAGE_NAME}" "$@" >/dev/null + "${IMAGE_NAME:?}" "$@" >/dev/null printf -- '%s\n\n' 'Done!' -exec docker logs -f "${CONTAINER_NAME}" +exec "${DOCKER:?}" logs -f "${CONTAINER_NAME:?}" diff --git a/scripts/bin/docker-foreground-cmd b/scripts/bin/container-foreground-cmd similarity index 60% rename from scripts/bin/docker-foreground-cmd rename to scripts/bin/container-foreground-cmd index 42492cf..9ab9051 100755 --- a/scripts/bin/docker-foreground-cmd +++ b/scripts/bin/container-foreground-cmd @@ -4,7 +4,7 @@ set -eu # Create ReactOS disk if [ ! -f /var/lib/qemu/images/reactos.img ]; then - qemu-img create -f "${QEMU_DISK_FORMAT}" /var/lib/qemu/images/reactos.img "${QEMU_DISK_SIZE}" + qemu-img create -f "${QEMU_DISK_FORMAT:?}" /var/lib/qemu/images/reactos.img "${QEMU_DISK_SIZE:?}" fi # Start all services diff --git a/scripts/service/qemu/run b/scripts/service/qemu/run index 10c5a99..0c1a5d8 100755 --- a/scripts/service/qemu/run +++ b/scripts/service/qemu/run @@ -3,16 +3,16 @@ set -eu QEMU=$(command -v qemu-system-x86_64) -QEMU_ARGS="${QEMU_ARGS-} -smp ${QEMU_CPU} -m ${QEMU_RAM}" +QEMU_ARGS="${QEMU_ARGS-} -smp ${QEMU_CPU:?} -m ${QEMU_RAM:?}" QEMU_ARGS="${QEMU_ARGS-} -vga std -display vnc=:0" -QEMU_ARGS="${QEMU_ARGS-} -drive file=/var/lib/qemu/images/reactos.img,index=0,media=disk,format=${QEMU_DISK_FORMAT}" +QEMU_ARGS="${QEMU_ARGS-} -drive file=/var/lib/qemu/images/reactos.img,index=0,media=disk,format=${QEMU_DISK_FORMAT:?}" QEMU_ARGS="${QEMU_ARGS-} -drive file=/var/lib/qemu/iso/reactos.iso,index=2,media=cdrom,format=raw" -QEMU_ARGS="${QEMU_ARGS-} -boot order=${QEMU_BOOT_ORDER},menu=${QEMU_BOOT_MENU},splash-time=5000" -QEMU_ARGS="${QEMU_ARGS-} -netdev user,id=n0,${QEMU_NET_OPTIONS} -device ${QEMU_NET_DEVICE},netdev=n0" +QEMU_ARGS="${QEMU_ARGS-} -boot order=${QEMU_BOOT_ORDER:?},menu=${QEMU_BOOT_MENU:?},splash-time=5000" +QEMU_ARGS="${QEMU_ARGS-} -netdev user,id=n0,${QEMU_NET_OPTIONS:?} -device ${QEMU_NET_DEVICE:?},netdev=n0" QEMU_ARGS="${QEMU_ARGS-} -usb -device usb-tablet" -QEMU_ARGS="${QEMU_ARGS-} -k ${QEMU_KEYBOARD}" -if [ "${QEMU_KVM}" = true ]; then QEMU_ARGS="${QEMU_ARGS-} -enable-kvm"; fi +QEMU_ARGS="${QEMU_ARGS-} -k ${QEMU_KEYBOARD:?}" +if [ "${QEMU_KVM:?}" = true ]; then QEMU_ARGS="${QEMU_ARGS-} -enable-kvm"; fi cd ~/ exec 2>&1 -exec "${QEMU}" ${QEMU_ARGS} +exec "${QEMU:?}" ${QEMU_ARGS:?}