chore: cleanup: drop prepare_images
This commit is contained in:
parent
0dc241b63c
commit
33107bf3ae
@ -4,8 +4,6 @@
|
||||
# resource
|
||||
resource/deploy
|
||||
resource/frontend
|
||||
resource/runner/.mark.image
|
||||
resource/runner/problem/*
|
||||
resource/runner/tmp/*
|
||||
resource/runner/user/*
|
||||
|
||||
|
2
Makefile
2
Makefile
@ -24,7 +24,7 @@ build: swagger dep
|
||||
$(GOBUILD) -o woj ./cmd/woj
|
||||
|
||||
clean:
|
||||
rm -f woj
|
||||
rm -f woj coverage.out coverage.html
|
||||
|
||||
dep:
|
||||
go mod download
|
||||
|
@ -35,7 +35,7 @@ func NewRunner(i *do.Injector) (Handler, error) {
|
||||
storageService: do.MustInvoke[storage.Service](i),
|
||||
}
|
||||
|
||||
status := hnd.runnerService.EnsureDeps(false)
|
||||
status := hnd.runnerService.EnsureDeps()
|
||||
if status != e.Success {
|
||||
hnd.log.Error("failed to ensure runner dependencies", zap.String("status", status.String()))
|
||||
return nil, errors.New("failed to ensure dependencies")
|
||||
|
@ -61,16 +61,7 @@ func (s *service) LoadImage(cfg *depConfig) e.Status {
|
||||
return e.Success
|
||||
}
|
||||
|
||||
func (s *service) EnsureDeps(force bool) e.Status {
|
||||
mark := filepath.Join(Prefix, ".mark.image")
|
||||
|
||||
// check mark
|
||||
if force {
|
||||
_ = os.Remove(mark)
|
||||
} else if file.Exist(mark) {
|
||||
return e.Success
|
||||
}
|
||||
|
||||
func (s *service) EnsureDeps() e.Status {
|
||||
// full
|
||||
fullImage := &depConfig{
|
||||
tarball: filepath.Join(TmpDir, "ubuntu-full.tar.gz"),
|
||||
@ -89,8 +80,5 @@ func (s *service) EnsureDeps(force bool) e.Status {
|
||||
return e.RunnerDepsBuildFailed
|
||||
}
|
||||
|
||||
// mark
|
||||
_, _ = os.Create(mark)
|
||||
|
||||
return e.Success
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ var _ Service = (*service)(nil)
|
||||
|
||||
type Service interface {
|
||||
// EnsureDeps build docker images
|
||||
EnsureDeps(force bool) e.Status
|
||||
EnsureDeps() e.Status
|
||||
// NewProblem = Download + Parse + Prebuild
|
||||
NewProblem(meta *JudgeMeta, url string, force bool) (*Config, e.Status)
|
||||
|
||||
|
2
resource/runner/.gitignore
vendored
2
resource/runner/.gitignore
vendored
@ -1,4 +1,2 @@
|
||||
# docker image mark
|
||||
.mark.*
|
||||
# other tmp files
|
||||
*.zip
|
||||
|
@ -1,53 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPT_PATH=$(cd "$(dirname "$0")" && pwd)
|
||||
. "$SCRIPT_PATH/common.sh"
|
||||
|
||||
cd "$(dirname "$0")"/../ || exit 1
|
||||
|
||||
# Check Mark
|
||||
if [ -f ./.mark.image ]; then
|
||||
log_warn "Docker images already prepared"
|
||||
log_warn "If you want to re-prepare the images, please remove the file $(pwd)/.mark.image"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Preparing image..."
|
||||
log_info "Checking $DOCKER - $($DOCKER --version)"
|
||||
|
||||
# Full
|
||||
if [ -f ./tmp/ubuntu-full.tar.gz ]; then
|
||||
log_info "Importing Full Image"
|
||||
gzip -d -c ./tmp/ubuntu-full.tar.gz | $DOCKER load || (log_error "Import Full Image failed" && exit 1)
|
||||
else
|
||||
log_info "Pulling Full Image"
|
||||
if ! $DOCKER pull git.0x7f.app/woj/ubuntu-full:latest; then
|
||||
log_warn "Pull failed, building from scratch"
|
||||
log_info "Building Full Image"
|
||||
$DOCKER build -t git.0x7f.app/woj/ubuntu-full:latest -f scripts/ubuntu-full.Dockerfile . || (log_error "Build Full Image failed" && exit 1)
|
||||
fi
|
||||
fi
|
||||
|
||||
# Tiny
|
||||
if [ -f ./tmp/ubuntu-tiny.tar.gz ]; then
|
||||
log_info "Importing Tiny Image"
|
||||
gzip -d -c ./tmp/ubuntu-tiny.tar.gz | $DOCKER load || (log_error "Import Tiny Image failed" && exit 1)
|
||||
else
|
||||
log_info "Pulling Tiny Image"
|
||||
if ! $DOCKER pull git.0x7f.app/woj/ubuntu-run:latest; then
|
||||
log_warn "Pull failed, building from scratch"
|
||||
log_info "Building Tiny Image"
|
||||
$DOCKER build -t git.0x7f.app/woj/ubuntu-run:latest -f scripts/ubuntu-run.Dockerfile . || (log_error "Build Tiny Image failed" && exit 1)
|
||||
fi
|
||||
fi
|
||||
|
||||
# Mark
|
||||
if [ "$1" == "save" ]; then
|
||||
log_info "Saving Images"
|
||||
$DOCKER save git.0x7f.app/woj/ubuntu-full:latest | gzip -9 >./tmp/ubuntu-full.tar.gz
|
||||
$DOCKER save git.0x7f.app/woj/ubuntu-run:latest | gzip -9 >./tmp/ubuntu-tiny.tar.gz
|
||||
else
|
||||
touch ./.mark.image
|
||||
fi
|
||||
|
||||
log_info "Done"
|
Loading…
Reference in New Issue
Block a user