Compare commits
No commits in common. "e6a6da7a78b1be106d69db8e519594910ea72988" and "9d13f8216f7417679205d74bdc841cd430ea47da" have entirely different histories.
e6a6da7a78
...
9d13f8216f
4 changed files with 15 additions and 57 deletions
33
Makefile
33
Makefile
|
@ -1,37 +1,6 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
# Copyright © 2023 Glenn Y. Rolland <glenux@glenux.net>
|
|
||||||
|
|
||||||
CURRENT_UID := $(shell id -u)
|
|
||||||
CURRENT_GID := $(shell id -g)
|
|
||||||
ifeq ($(CURRENT_UID),0)
|
|
||||||
PREFIX=/usr
|
|
||||||
else
|
|
||||||
PREFIX=$(HOME)/.local
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
prepare:
|
|
||||||
shards install
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
shards build --error-trace -Dpreview_mt
|
shards build --error-trace
|
||||||
@echo SUCCESS
|
|
||||||
|
|
||||||
watch:
|
|
||||||
watchexec --restart --delay-run 3 -c -e cr make build
|
|
||||||
|
|
||||||
spec: test
|
|
||||||
test:
|
|
||||||
crystal spec --error-trace
|
|
||||||
|
|
||||||
install:
|
|
||||||
install \
|
|
||||||
-m 755 \
|
|
||||||
bin/docmachine \
|
|
||||||
$(PREFIX)/bin
|
|
||||||
|
|
||||||
.PHONY: spec test build all prepare install
|
|
||||||
|
|
|
@ -20,10 +20,6 @@ module DocMachine::Build
|
||||||
config.action = action
|
config.action = action
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on("--no-cache", "Disable cache") do |_|
|
|
||||||
config.enable_cache = false
|
|
||||||
end
|
|
||||||
|
|
||||||
opts.on("-d", "--data-dir DIR", "Content directory") do |dir|
|
opts.on("-d", "--data-dir DIR", "Content directory") do |dir|
|
||||||
config.data_dir = dir
|
config.data_dir = dir
|
||||||
end
|
end
|
||||||
|
@ -33,7 +29,7 @@ module DocMachine::Build
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on("-m", "--multiple", "Allow multiple instances per dir" ) do |port|
|
opts.on("-m", "--multiple", "Allow multiple instances per dir" ) do |port|
|
||||||
config.enable_multiple = true
|
config.multiple_instances = true
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on("-t", "--tty", "Enable TTY mode (needed for shell)") do
|
opts.on("-t", "--tty", "Enable TTY mode (needed for shell)") do
|
||||||
|
|
|
@ -5,8 +5,7 @@ module DocMachine::Build
|
||||||
property action : String = "watch"
|
property action : String = "watch"
|
||||||
property enable_tty : Bool = false
|
property enable_tty : Bool = false
|
||||||
property port : Int32 = 5100
|
property port : Int32 = 5100
|
||||||
property enable_multiple : Bool = false
|
property multiple_instances : Bool = false
|
||||||
property enable_cache : Bool = false
|
|
||||||
|
|
||||||
def initialize(@parent : DocMachine::Config)
|
def initialize(@parent : DocMachine::Config)
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ module DocMachine::Build
|
||||||
Log.info { "action = #{@config.action}" }
|
Log.info { "action = #{@config.action}" }
|
||||||
|
|
||||||
self._pull_image()
|
self._pull_image()
|
||||||
self._avoid_duplicates() unless @config.enable_multiple
|
self._avoid_duplicates() unless @config.multiple_instances
|
||||||
end
|
end
|
||||||
|
|
||||||
private def _find_port(port_base)
|
private def _find_port(port_base)
|
||||||
|
@ -68,7 +68,6 @@ module DocMachine::Build
|
||||||
else Path[ENV["HOME"], ".cache", "docmachine"]
|
else Path[ENV["HOME"], ".cache", "docmachine"]
|
||||||
end
|
end
|
||||||
|
|
||||||
## Build cache if it doesnt exist
|
|
||||||
data_cache_file = data_cache_dir / "image.tar"
|
data_cache_file = data_cache_dir / "image.tar"
|
||||||
Log.info { "Checking cache #{data_cache_file}..." }
|
Log.info { "Checking cache #{data_cache_file}..." }
|
||||||
if ! File.exists? data_cache_file.to_s
|
if ! File.exists? data_cache_file.to_s
|
||||||
|
@ -92,7 +91,6 @@ module DocMachine::Build
|
||||||
Log.info { "Cache already exist. Skipping." }
|
Log.info { "Cache already exist. Skipping." }
|
||||||
end
|
end
|
||||||
|
|
||||||
if @config.enable_cache
|
|
||||||
Log.info { "Loading #{@docker_image} image from cache..." }
|
Log.info { "Loading #{@docker_image} image from cache..." }
|
||||||
docker_image_loaded = false
|
docker_image_loaded = false
|
||||||
status = Process.run(
|
status = Process.run(
|
||||||
|
@ -106,10 +104,6 @@ module DocMachine::Build
|
||||||
Log.error { "Unable to load cache image" }
|
Log.error { "Unable to load cache image" }
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
else
|
|
||||||
Log.info { "Loading #{@docker_image} image from local registry..." }
|
|
||||||
# FIXME: check that local image exists
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def start()
|
def start()
|
||||||
|
|
Loading…
Reference in a new issue