mirror of
https://github.com/hectorm/docker-qemu-reactos
synced 2025-01-08 01:55:30 +00:00
Made configurable image registry and small improvements in the building system
This commit is contained in:
parent
4767b81127
commit
7c7421f12e
@ -15,7 +15,7 @@ build:image:
|
||||
stage: build:images
|
||||
before_script:
|
||||
- docker info
|
||||
- apk add --no-cache coreutils git make
|
||||
- apk add --no-cache coreutils git make xz
|
||||
script:
|
||||
- make build-image save-image
|
||||
artifacts:
|
||||
@ -26,8 +26,8 @@ build:image:
|
||||
push:image:
|
||||
stage: push:images
|
||||
before_script:
|
||||
- apk add --no-cache coreutils git make
|
||||
- docker login -u "${CI_DEPLOY_USER}" -p "${CI_DEPLOY_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
|
||||
only:
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM debian:sid
|
||||
FROM docker.io/debian:sid
|
||||
|
||||
# Environment
|
||||
ENV QEMU_CPU=2
|
||||
|
34
Makefile
34
Makefile
@ -7,22 +7,20 @@ DOCKER := $(shell command -v docker 2>/dev/null)
|
||||
GIT := $(shell command -v git 2>/dev/null)
|
||||
|
||||
DISTDIR := ./dist
|
||||
VERSION_FILE = ./VERSION
|
||||
DOCKERFILE := ./Dockerfile
|
||||
|
||||
IMAGE_REGISTRY := docker.io
|
||||
IMAGE_NAMESPACE := hectormolinero
|
||||
IMAGE_NAME := qemu-reactos
|
||||
IMAGE_VERSION := v0
|
||||
IMAGE_PROJECT := qemu-reactos
|
||||
IMAGE_NAME := $(IMAGE_REGISTRY)/$(IMAGE_NAMESPACE)/$(IMAGE_PROJECT)
|
||||
|
||||
# If git is available and the directory is a repository, use the latest tag as IMAGE_VERSION.
|
||||
ifeq ([$(notdir $(GIT))][$(wildcard .git/.)],[git][.git/.])
|
||||
IMAGE_VERSION := $(shell '$(GIT)' describe --abbrev=0 --tags 2>/dev/null || printf '%s' '$(IMAGE_VERSION)')
|
||||
IMAGE_VERSION := v0
|
||||
ifneq ($(wildcard $(VERSION_FILE)),)
|
||||
IMAGE_VERSION := $(shell cat '$(VERSION_FILE)')
|
||||
endif
|
||||
|
||||
IMAGE_LATEST_TAG := $(IMAGE_NAMESPACE)/$(IMAGE_NAME):latest
|
||||
IMAGE_VERSION_TAG := $(IMAGE_NAMESPACE)/$(IMAGE_NAME):$(IMAGE_VERSION)
|
||||
|
||||
IMAGE_TARBALL := $(DISTDIR)/$(IMAGE_NAME).tgz
|
||||
|
||||
DOCKERFILE := ./Dockerfile
|
||||
IMAGE_TARBALL := $(DISTDIR)/$(IMAGE_PROJECT).txz
|
||||
|
||||
##################################################
|
||||
## "all" target
|
||||
@ -38,8 +36,8 @@ all: save-image
|
||||
.PHONY: build-image
|
||||
build-image:
|
||||
'$(DOCKER)' build \
|
||||
--tag '$(IMAGE_VERSION_TAG)' \
|
||||
--tag '$(IMAGE_LATEST_TAG)' \
|
||||
--tag '$(IMAGE_NAME):$(IMAGE_VERSION)' \
|
||||
--tag '$(IMAGE_NAME):latest' \
|
||||
--file '$(DOCKERFILE)' ./
|
||||
|
||||
##################################################
|
||||
@ -47,7 +45,7 @@ build-image:
|
||||
##################################################
|
||||
|
||||
define save_image
|
||||
'$(DOCKER)' save '$(1)' | gzip -n > '$(2)'
|
||||
'$(DOCKER)' save '$(1)' | xz -T0 > '$(2)'
|
||||
endef
|
||||
|
||||
.PHONY: save-image
|
||||
@ -55,7 +53,7 @@ save-image: $(IMAGE_TARBALL)
|
||||
|
||||
$(IMAGE_TARBALL): build-image
|
||||
mkdir -p '$(DISTDIR)'
|
||||
$(call save_image,$(IMAGE_VERSION_TAG),$@)
|
||||
$(call save_image,$(IMAGE_NAME):$(IMAGE_VERSION),$@)
|
||||
|
||||
##################################################
|
||||
## "load-*" targets
|
||||
@ -72,7 +70,7 @@ endef
|
||||
.PHONY: load-image
|
||||
load-image:
|
||||
$(call load_image,$(IMAGE_TARBALL))
|
||||
$(call tag_image,$(IMAGE_VERSION_TAG),$(IMAGE_LATEST_TAG))
|
||||
$(call tag_image,$(IMAGE_NAME):$(IMAGE_VERSION),$(IMAGE_NAME):latest)
|
||||
|
||||
##################################################
|
||||
## "push-*" targets
|
||||
@ -84,8 +82,8 @@ endef
|
||||
|
||||
.PHONY: push-image
|
||||
push-image:
|
||||
$(call push_image,$(IMAGE_VERSION_TAG))
|
||||
$(call push_image,$(IMAGE_LATEST_TAG))
|
||||
$(call push_image,$(IMAGE_NAME):$(IMAGE_VERSION))
|
||||
$(call push_image,$(IMAGE_NAME):latest)
|
||||
|
||||
##################################################
|
||||
## "version" target
|
||||
|
36
run.sh
36
run.sh
@ -3,42 +3,42 @@
|
||||
set -eu
|
||||
export LC_ALL=C
|
||||
|
||||
DOCKER_IMAGE_NAMESPACE=hectormolinero
|
||||
DOCKER_IMAGE_NAME=qemu-reactos
|
||||
DOCKER_IMAGE_VERSION=latest
|
||||
DOCKER_IMAGE=${DOCKER_IMAGE_NAMESPACE}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}
|
||||
DOCKER_CONTAINER=${DOCKER_IMAGE_NAME}
|
||||
IMAGE_NAMESPACE=hectormolinero
|
||||
IMAGE_PROJECT=qemu-reactos
|
||||
IMAGE_TAG=latest
|
||||
IMAGE_NAME=${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"; }
|
||||
|
||||
if ! imageExists "${DOCKER_IMAGE}"; then
|
||||
>&2 printf -- '%s\n' "${DOCKER_IMAGE} image doesn't exist!"
|
||||
if ! imageExists "${IMAGE_NAME}"; then
|
||||
>&2 printf -- '%s\n' "${IMAGE_NAME} image doesn't exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if containerIsRunning "${DOCKER_CONTAINER}"; then
|
||||
printf -- '%s\n' "Stopping \"${DOCKER_CONTAINER}\" container..."
|
||||
docker stop "${DOCKER_CONTAINER}" >/dev/null
|
||||
if containerIsRunning "${CONTAINER_NAME}"; then
|
||||
printf -- '%s\n' "Stopping \"${CONTAINER_NAME}\" container..."
|
||||
docker stop "${CONTAINER_NAME}" >/dev/null
|
||||
fi
|
||||
|
||||
if containerExists "${DOCKER_CONTAINER}"; then
|
||||
printf -- '%s\n' "Removing \"${DOCKER_CONTAINER}\" container..."
|
||||
docker rm "${DOCKER_CONTAINER}" >/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 \"${DOCKER_CONTAINER}\" container..."
|
||||
printf -- '%s\n' "Creating \"${CONTAINER_NAME}\" container..."
|
||||
docker run --detach \
|
||||
--name "${DOCKER_CONTAINER}" \
|
||||
--hostname "${DOCKER_CONTAINER}" \
|
||||
--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 \
|
||||
"${DOCKER_IMAGE}" "$@" >/dev/null
|
||||
"${IMAGE_NAME}" "$@" >/dev/null
|
||||
|
||||
printf -- '%s\n\n' 'Done!'
|
||||
exec docker logs -f "${DOCKER_CONTAINER}"
|
||||
exec docker logs -f "${CONTAINER_NAME}"
|
||||
|
Loading…
Reference in New Issue
Block a user