Runtime image and further Makefile updates
This commit is contained in:
parent
eeadee7349
commit
93507ce964
|
@ -2,7 +2,5 @@
|
||||||
**/*.log
|
**/*.log
|
||||||
**/.env
|
**/.env
|
||||||
**/.terraform
|
**/.terraform
|
||||||
**/debs
|
**/build
|
||||||
**/node_modules
|
**/node_modules
|
||||||
**/pkg
|
|
||||||
**/work
|
|
||||||
|
|
42
Makefile
42
Makefile
|
@ -3,9 +3,13 @@ SHELL := bash
|
||||||
|
|
||||||
export PATH := bin:$(PATH)
|
export PATH := bin:$(PATH)
|
||||||
|
|
||||||
include .env
|
-include .env
|
||||||
export
|
export
|
||||||
|
|
||||||
|
BUILD := build/$(T)/$(L)
|
||||||
|
DEB := riju-$(T)-$(L).deb
|
||||||
|
S3_DEB := s3://$(S3_BUCKET_BASE)-debs/debs/$(T)/$(L)/$(DEB)
|
||||||
|
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
help:
|
help:
|
||||||
@echo "usage:"
|
@echo "usage:"
|
||||||
|
@ -29,16 +33,20 @@ runtime-image:
|
||||||
app-image:
|
app-image:
|
||||||
docker build . -f docker/app/Dockerfile -t riju-app --pull
|
docker build . -f docker/app/Dockerfile -t riju-app --pull
|
||||||
|
|
||||||
|
.PHONY: script
|
||||||
|
script:
|
||||||
|
@: $${L} $${T}
|
||||||
|
mkdir -p $(BUILD)
|
||||||
|
node src/packager/make-script --lang $(L) --type $(T) > $(BUILD)/build.bash
|
||||||
|
chmod +x $(BUILD)/build.bash
|
||||||
|
|
||||||
.PHONY: pkg
|
.PHONY: pkg
|
||||||
pkg:
|
pkg:
|
||||||
@: $${L}
|
@: $${L} $${T}
|
||||||
mkdir -p build/$(L)
|
rm -rf $(BUILD)/src $(BUILD)/pkg
|
||||||
node src/packager/make-script $(L) > build/$(L)/build.bash
|
mkdir -p $(BUILD)/src $(BUILD)/pkg
|
||||||
chmod +x build/$(L)/build.bash
|
cd $(BUILD)/src && pkg="$(PWD)/$(BUILD)/pkg" ../build.bash
|
||||||
rm -rf build/$(L)/src build/$(L)/pkg
|
fakeroot dpkg-deb --build $(BUILD)/pkg $(BUILD)/$(DEB)
|
||||||
mkdir -p build/$(L)/src build/$(L)/pkg
|
|
||||||
cd build/$(L)/src && pkg="$(PWD)/build/$(L)/pkg" ../build.bash
|
|
||||||
fakeroot dpkg-deb --build build/$(L)/pkg build/$(L)/$(L).deb
|
|
||||||
|
|
||||||
### Run things inside Docker
|
### Run things inside Docker
|
||||||
|
|
||||||
|
@ -54,46 +62,52 @@ runtime-shell:
|
||||||
|
|
||||||
.PHONY: fetch-packaging-image
|
.PHONY: fetch-packaging-image
|
||||||
fetch-packaging-image:
|
fetch-packaging-image:
|
||||||
|
@: $${DOCKER_REPO_BASE}
|
||||||
docker pull $(DOCKER_REPO_BASE)-packaging
|
docker pull $(DOCKER_REPO_BASE)-packaging
|
||||||
docker tag $(DOCKER_REPO_BASE)-packaging riju-packaging
|
docker tag $(DOCKER_REPO_BASE)-packaging riju-packaging
|
||||||
|
|
||||||
.PHONY: fetch-runtime-image
|
.PHONY: fetch-runtime-image
|
||||||
fetch-runtime-image:
|
fetch-runtime-image:
|
||||||
|
@: $${DOCKER_REPO_BASE}
|
||||||
docker pull $(DOCKER_REPO_BASE)-runtime
|
docker pull $(DOCKER_REPO_BASE)-runtime
|
||||||
docker tag $(DOCKER_REPO_BASE)-runtime riju-runtime
|
docker tag $(DOCKER_REPO_BASE)-runtime riju-runtime
|
||||||
|
|
||||||
.PHONY: fetch-app-image
|
.PHONY: fetch-app-image
|
||||||
fetch-app-image:
|
fetch-app-image:
|
||||||
|
@: $${DOCKER_REPO_BASE}
|
||||||
docker pull $(DOCKER_REPO_BASE)-app
|
docker pull $(DOCKER_REPO_BASE)-app
|
||||||
docker tag $(DOCKER_REPO_BASE)-app riju-app
|
docker tag $(DOCKER_REPO_BASE)-app riju-app
|
||||||
|
|
||||||
.PHONY: fetch-pkg
|
.PHONY: fetch-pkg
|
||||||
fetch-pkg:
|
fetch-pkg:
|
||||||
@: $${L}
|
@: $${L} $${T} $${S3_BUCKET_BASE}
|
||||||
mkdir -p build/$(L)
|
mkdir -p $(BUILD)
|
||||||
aws s3 cp s3://$(S3_BUCKET_BASE)-debs/debs/$(L).deb build/$(L)/$(L).deb
|
aws s3 cp $(S3_DEB) $(BUILD)/$(DEB)
|
||||||
|
|
||||||
### Publish things to registries
|
### Publish things to registries
|
||||||
|
|
||||||
.PHONY: publish-packaging-image
|
.PHONY: publish-packaging-image
|
||||||
publish-packaging-image:
|
publish-packaging-image:
|
||||||
|
@: $${DOCKER_REPO_BASE}
|
||||||
docker tag riju-packaging $(DOCKER_REPO_BASE)-packaging
|
docker tag riju-packaging $(DOCKER_REPO_BASE)-packaging
|
||||||
docker push $(DOCKER_REPO_BASE)-packaging
|
docker push $(DOCKER_REPO_BASE)-packaging
|
||||||
|
|
||||||
.PHONY: publish-runtime-image
|
.PHONY: publish-runtime-image
|
||||||
publish-runtime-image:
|
publish-runtime-image:
|
||||||
|
@: $${DOCKER_REPO_BASE}
|
||||||
docker tag riju-runtime $(DOCKER_REPO_BASE)-runtime
|
docker tag riju-runtime $(DOCKER_REPO_BASE)-runtime
|
||||||
docker push $(DOCKER_REPO_BASE)-runtime
|
docker push $(DOCKER_REPO_BASE)-runtime
|
||||||
|
|
||||||
.PHONY: publish-app-image
|
.PHONY: publish-app-image
|
||||||
publish-app-image:
|
publish-app-image:
|
||||||
|
@: $${DOCKER_REPO_BASE}
|
||||||
docker tag riju-app $(DOCKER_REPO_BASE)-app
|
docker tag riju-app $(DOCKER_REPO_BASE)-app
|
||||||
docker push $(DOCKER_REPO_BASE)-app
|
docker push $(DOCKER_REPO_BASE)-app
|
||||||
|
|
||||||
.PHONY: publish-pkg
|
.PHONY: publish-pkg
|
||||||
publish-pkg:
|
publish-pkg:
|
||||||
@: $${L}
|
@: $${L} $${T} $${S3_BUCKET_BASE}
|
||||||
aws s3 cp build/$(L)/$(L).deb s3://$(S3_BUCKET_BASE)-debs/debs/$(L).deb
|
aws s3 cp $(BUILD)/$(DEB) $(S3_DEB)
|
||||||
|
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
FROM ubuntu:rolling
|
||||||
|
|
||||||
|
COPY docker/runtime/install.bash /tmp/
|
||||||
|
RUN /tmp/install.bash
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
COPY docker/runtime/pid1.bash /usr/local/sbin/
|
||||||
|
ENTRYPOINT ["/usr/local/sbin/pid1.bash"]
|
||||||
|
CMD ["bash"]
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
apt-get update
|
||||||
|
(yes || true) | unminimize
|
||||||
|
|
||||||
|
apt-get install -y curl gnupg lsb-release
|
||||||
|
|
||||||
|
curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
|
||||||
|
curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
||||||
|
|
||||||
|
ubuntu_ver="$(lsb_release -rs)"
|
||||||
|
ubuntu_name="$(lsb_release -cs)"
|
||||||
|
|
||||||
|
node_repo="$(curl -sS https://deb.nodesource.com/setup_current.x | grep NODEREPO= | grep -Eo 'node_[0-9]+\.x' | head -n1)"
|
||||||
|
|
||||||
|
tee -a /etc/apt/sources.list.d/custom.list >/dev/null <<EOF
|
||||||
|
deb https://deb.nodesource.com/${node_repo} ${ubuntu_name} main
|
||||||
|
deb https://dl.yarnpkg.com/debian/ stable main
|
||||||
|
EOF
|
||||||
|
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y dctrl-tools
|
||||||
|
|
||||||
|
libicu="$(grep-aptavail -wF Package 'libicu[0-9]+' -s Package -n | head -n1)"
|
||||||
|
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y less "${libicu}" make man nodejs sudo yarn
|
||||||
|
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
tee /etc/sudoers.d/90-riju >/dev/null <<"EOF"
|
||||||
|
%sudo ALL=(ALL:ALL) NOPASSWD: ALL
|
||||||
|
EOF
|
||||||
|
|
||||||
|
rm "$0"
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
groupadd -g "$(stat -c %g "$PWD")" -o -p '!' -r riju
|
||||||
|
useradd -u "$(stat -c %u "$PWD")" -g "$(stat -c %g "$PWD")" -o -m -N -l -s /usr/bin/bash -G sudo riju
|
||||||
|
|
||||||
|
runuser -u riju touch /home/riju/.sudo_as_admin_successful
|
||||||
|
|
||||||
|
exec runuser -u riju "$@"
|
|
@ -18,7 +18,7 @@ install:
|
||||||
wget "$(curl -sSL "https://pvsc.blob.core.windows.net/python-language-server-stable?restype=container&comp=list&prefix=Python-Language-Server-linux-x64" | grep -Eo 'https://[^<]+\.nupkg' | tail -n1)"
|
wget "$(curl -sSL "https://pvsc.blob.core.windows.net/python-language-server-stable?restype=container&comp=list&prefix=Python-Language-Server-linux-x64" | grep -Eo 'https://[^<]+\.nupkg' | tail -n1)"
|
||||||
unzip -d "${pkg}/opt/mspyls" Python-Language-Server-linux-x64.*.nupkg
|
unzip -d "${pkg}/opt/mspyls" Python-Language-Server-linux-x64.*.nupkg
|
||||||
chmod +x "${pkg}/opt/mspyls/Microsoft.Python.LanguageServer"
|
chmod +x "${pkg}/opt/mspyls/Microsoft.Python.LanguageServer"
|
||||||
ln -s "${pkg}/opt/mspyls/Microsoft.Python.LanguageServer" "${pkg}/usr/local/bin/Microsoft.Python.LanguageServer"
|
ln -s "/opt/mspyls/Microsoft.Python.LanguageServer" "${pkg}/usr/local/bin/Microsoft.Python.LanguageServer"
|
||||||
|
|
||||||
repl: >-
|
repl: >-
|
||||||
python3 -u
|
python3 -u
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"commander": "^6.2.1",
|
||||||
"yaml": "^1.10.0"
|
"yaml": "^1.10.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
import process from "process";
|
import process from "process";
|
||||||
|
|
||||||
|
import { Command } from "commander";
|
||||||
|
|
||||||
import { readLangConfig } from "../config.js";
|
import { readLangConfig } from "../config.js";
|
||||||
|
|
||||||
// Given a language config object, return the text of a Bash script
|
// Given a language config object, return the text of a Bash script
|
||||||
// that will build the (unpacked) Debian package into ${pkg} when run in an
|
// that will build the (unpacked) riju-lang-foo Debian package into
|
||||||
// appropriate environment.
|
// ${pkg} when run in an appropriate environment. This is a package
|
||||||
function makeScript(langConfig) {
|
// that will install the language interpreter/compiler and associated
|
||||||
|
// tools.
|
||||||
|
function makeLangScript(langConfig) {
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
|
@ -19,7 +23,7 @@ function makeScript(langConfig) {
|
||||||
set -euxo pipefail`);
|
set -euxo pipefail`);
|
||||||
let debianControlData = `\
|
let debianControlData = `\
|
||||||
Package: riju-lang-${id}
|
Package: riju-lang-${id}
|
||||||
Version: ${timestamp}
|
Version: \$(date +%s%3N)
|
||||||
Architecture: amd64
|
Architecture: amd64
|
||||||
Maintainer: Radon Rosborough <radon.neon@gmail.com>
|
Maintainer: Radon Rosborough <radon.neon@gmail.com>
|
||||||
Description: The ${name} language packaged for Riju`;
|
Description: The ${name} language packaged for Riju`;
|
||||||
|
@ -29,7 +33,7 @@ Depends: ${apt.join(", ")}`;
|
||||||
}
|
}
|
||||||
parts.push(`\
|
parts.push(`\
|
||||||
install -d "\${pkg}/DEBIAN"
|
install -d "\${pkg}/DEBIAN"
|
||||||
cat <<"EOF" > "\${pkg}/DEBIAN/control"
|
cat <<EOF > "\${pkg}/DEBIAN/control"
|
||||||
${debianControlData}
|
${debianControlData}
|
||||||
EOF`);
|
EOF`);
|
||||||
for (const part of manual || []) {
|
for (const part of manual || []) {
|
||||||
|
@ -38,14 +42,45 @@ EOF`);
|
||||||
return parts.join("\n\n");
|
return parts.join("\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Given a language config object, return the text of a Bash script
|
||||||
|
// that will build the (unpacked) riju-config-foo Debian package into
|
||||||
|
// ${pkg} when run in an appropriate environment. This is a package
|
||||||
|
// that will install configuration files and/or small scripts that
|
||||||
|
// encode the language configuration so that Riju can operate on any
|
||||||
|
// installed languages without knowing their configuration in advance.
|
||||||
|
function makeConfigScript(langConfig) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
// Given a language config object, return the text of a Bash script
|
||||||
|
// that will build the (unpacked) riju-shared-foo Debian package into
|
||||||
|
// ${pkg} when run in an appropriate environment. This is a package
|
||||||
|
// that installs tools used by multiple languages, and can be declared
|
||||||
|
// as a dependency.
|
||||||
|
function makeSharedScript(langConfig) {
|
||||||
|
throw new Error("shared script generation not implemented yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse command-line arguments, run main functionality, and exit.
|
||||||
async function main() {
|
async function main() {
|
||||||
const args = process.argv.slice(2);
|
const program = new Command();
|
||||||
if (args.length !== 1) {
|
program
|
||||||
console.error("usage: script-maker.js LANG");
|
.requiredOption("--lang <id>", "language ID")
|
||||||
|
.requiredOption(
|
||||||
|
"--type <value>",
|
||||||
|
"package category (lang, config, shared)"
|
||||||
|
);
|
||||||
|
program.parse(process.argv);
|
||||||
|
const scriptMaker = {
|
||||||
|
lang: makeLangScript,
|
||||||
|
config: makeConfigScript,
|
||||||
|
shared: makeSharedScript,
|
||||||
|
}[program.type];
|
||||||
|
if (!scriptMaker) {
|
||||||
|
console.error(`make-script.js: unsupported --type ${program.type}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
const [lang] = args;
|
console.log(scriptMaker(await readLangConfig(program.lang)));
|
||||||
console.log(makeScript(await readLangConfig(lang)));
|
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
# yarn lockfile v1
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
commander@^6.2.1:
|
||||||
|
version "6.2.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c"
|
||||||
|
integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==
|
||||||
|
|
||||||
yaml@^1.10.0:
|
yaml@^1.10.0:
|
||||||
version "1.10.0"
|
version "1.10.0"
|
||||||
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
|
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
|
||||||
|
|
Loading…
Reference in New Issue