woj-server/build_image.sh
2023-12-18 21:14:33 +08:00

58 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
. resource/runner/scripts/common.sh
# version
VERSION="$(cat VERSION)"
log_info "VERSION: $VERSION"
function build_base() {
log_info "[+] Building Base Images"
pushd resource/runner || exit 1
$DOCKER build -t git.0x7f.app/woj/ubuntu-full:latest -f scripts/ubuntu-full.Dockerfile . ||
(log_error "Build Full Image failed" && exit 1)
$DOCKER build -t git.0x7f.app/woj/ubuntu-run:latest -f scripts/ubuntu-run.Dockerfile . ||
(log_error "Build Tiny Image failed" && exit 1)
popd
}
function push_base() {
log_info "[+] Pushing Base Images"
$DOCKER push "git.0x7f.app/woj/ubuntu-full:latest"
$DOCKER push "git.0x7f.app/woj/ubuntu-run:latest"
}
function build_server() {
log_info "[+] Building Server"
$DOCKER build -t "git.0x7f.app/woj/woj-server:$VERSION" -f Server.Dockerfile . ||
(log_error "[!] Failed to build Server" && exit 1)
}
function build_runner() {
log_info "[+] Building Runner"
$DOCKER build \
--cap-add=sys_admin,mknod \
--device=/dev/fuse \
--security-opt label=disable \
-t "git.0x7f.app/woj/woj-runner:$VERSION" \
-f Runner.Dockerfile . ||
(log_error "[!] Failed to build Runner" && exit 1)
}
function push_server() {
log_info "[+] Pushing Server Images"
$DOCKER push "git.0x7f.app/woj/woj-server:$VERSION"
}
function push_runner() {
log_info "[+] Pushing Runner Images"
$DOCKER push "git.0x7f.app/woj/woj-runner:$VERSION"
}
build_base
push_base
build_server
push_server
build_runner
push_runner