Runtime image and further Makefile updates
This commit is contained in:
parent
eeadee7349
commit
93507ce964
|
@ -2,7 +2,5 @@
|
|||
**/*.log
|
||||
**/.env
|
||||
**/.terraform
|
||||
**/debs
|
||||
**/build
|
||||
**/node_modules
|
||||
**/pkg
|
||||
**/work
|
||||
|
|
42
Makefile
42
Makefile
|
@ -3,9 +3,13 @@ SHELL := bash
|
|||
|
||||
export PATH := bin:$(PATH)
|
||||
|
||||
include .env
|
||||
-include .env
|
||||
export
|
||||
|
||||
BUILD := build/$(T)/$(L)
|
||||
DEB := riju-$(T)-$(L).deb
|
||||
S3_DEB := s3://$(S3_BUCKET_BASE)-debs/debs/$(T)/$(L)/$(DEB)
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@echo "usage:"
|
||||
|
@ -29,16 +33,20 @@ runtime-image:
|
|||
app-image:
|
||||
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
|
||||
pkg:
|
||||
@: $${L}
|
||||
mkdir -p build/$(L)
|
||||
node src/packager/make-script $(L) > build/$(L)/build.bash
|
||||
chmod +x build/$(L)/build.bash
|
||||
rm -rf build/$(L)/src build/$(L)/pkg
|
||||
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
|
||||
@: $${L} $${T}
|
||||
rm -rf $(BUILD)/src $(BUILD)/pkg
|
||||
mkdir -p $(BUILD)/src $(BUILD)/pkg
|
||||
cd $(BUILD)/src && pkg="$(PWD)/$(BUILD)/pkg" ../build.bash
|
||||
fakeroot dpkg-deb --build $(BUILD)/pkg $(BUILD)/$(DEB)
|
||||
|
||||
### Run things inside Docker
|
||||
|
||||
|
@ -54,46 +62,52 @@ runtime-shell:
|
|||
|
||||
.PHONY: fetch-packaging-image
|
||||
fetch-packaging-image:
|
||||
@: $${DOCKER_REPO_BASE}
|
||||
docker pull $(DOCKER_REPO_BASE)-packaging
|
||||
docker tag $(DOCKER_REPO_BASE)-packaging riju-packaging
|
||||
|
||||
.PHONY: fetch-runtime-image
|
||||
fetch-runtime-image:
|
||||
@: $${DOCKER_REPO_BASE}
|
||||
docker pull $(DOCKER_REPO_BASE)-runtime
|
||||
docker tag $(DOCKER_REPO_BASE)-runtime riju-runtime
|
||||
|
||||
.PHONY: fetch-app-image
|
||||
fetch-app-image:
|
||||
@: $${DOCKER_REPO_BASE}
|
||||
docker pull $(DOCKER_REPO_BASE)-app
|
||||
docker tag $(DOCKER_REPO_BASE)-app riju-app
|
||||
|
||||
.PHONY: fetch-pkg
|
||||
fetch-pkg:
|
||||
@: $${L}
|
||||
mkdir -p build/$(L)
|
||||
aws s3 cp s3://$(S3_BUCKET_BASE)-debs/debs/$(L).deb build/$(L)/$(L).deb
|
||||
@: $${L} $${T} $${S3_BUCKET_BASE}
|
||||
mkdir -p $(BUILD)
|
||||
aws s3 cp $(S3_DEB) $(BUILD)/$(DEB)
|
||||
|
||||
### Publish things to registries
|
||||
|
||||
.PHONY: publish-packaging-image
|
||||
publish-packaging-image:
|
||||
@: $${DOCKER_REPO_BASE}
|
||||
docker tag riju-packaging $(DOCKER_REPO_BASE)-packaging
|
||||
docker push $(DOCKER_REPO_BASE)-packaging
|
||||
|
||||
.PHONY: publish-runtime-image
|
||||
publish-runtime-image:
|
||||
@: $${DOCKER_REPO_BASE}
|
||||
docker tag riju-runtime $(DOCKER_REPO_BASE)-runtime
|
||||
docker push $(DOCKER_REPO_BASE)-runtime
|
||||
|
||||
.PHONY: publish-app-image
|
||||
publish-app-image:
|
||||
@: $${DOCKER_REPO_BASE}
|
||||
docker tag riju-app $(DOCKER_REPO_BASE)-app
|
||||
docker push $(DOCKER_REPO_BASE)-app
|
||||
|
||||
.PHONY: publish-pkg
|
||||
publish-pkg:
|
||||
@: $${L}
|
||||
aws s3 cp build/$(L)/$(L).deb s3://$(S3_BUCKET_BASE)-debs/debs/$(L).deb
|
||||
@: $${L} $${T} $${S3_BUCKET_BASE}
|
||||
aws s3 cp $(BUILD)/$(DEB) $(S3_DEB)
|
||||
|
||||
### 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)"
|
||||
unzip -d "${pkg}/opt/mspyls" Python-Language-Server-linux-x64.*.nupkg
|
||||
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: >-
|
||||
python3 -u
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"private": true,
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"commander": "^6.2.1",
|
||||
"yaml": "^1.10.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
import process from "process";
|
||||
|
||||
import { Command } from "commander";
|
||||
|
||||
import { readLangConfig } from "../config.js";
|
||||
|
||||
// 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
|
||||
// appropriate environment.
|
||||
function makeScript(langConfig) {
|
||||
// that will build the (unpacked) riju-lang-foo Debian package into
|
||||
// ${pkg} when run in an appropriate environment. This is a package
|
||||
// that will install the language interpreter/compiler and associated
|
||||
// tools.
|
||||
function makeLangScript(langConfig) {
|
||||
const {
|
||||
id,
|
||||
name,
|
||||
|
@ -19,7 +23,7 @@ function makeScript(langConfig) {
|
|||
set -euxo pipefail`);
|
||||
let debianControlData = `\
|
||||
Package: riju-lang-${id}
|
||||
Version: ${timestamp}
|
||||
Version: \$(date +%s%3N)
|
||||
Architecture: amd64
|
||||
Maintainer: Radon Rosborough <radon.neon@gmail.com>
|
||||
Description: The ${name} language packaged for Riju`;
|
||||
|
@ -29,7 +33,7 @@ Depends: ${apt.join(", ")}`;
|
|||
}
|
||||
parts.push(`\
|
||||
install -d "\${pkg}/DEBIAN"
|
||||
cat <<"EOF" > "\${pkg}/DEBIAN/control"
|
||||
cat <<EOF > "\${pkg}/DEBIAN/control"
|
||||
${debianControlData}
|
||||
EOF`);
|
||||
for (const part of manual || []) {
|
||||
|
@ -38,14 +42,45 @@ EOF`);
|
|||
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() {
|
||||
const args = process.argv.slice(2);
|
||||
if (args.length !== 1) {
|
||||
console.error("usage: script-maker.js LANG");
|
||||
const program = new Command();
|
||||
program
|
||||
.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);
|
||||
}
|
||||
const [lang] = args;
|
||||
console.log(makeScript(await readLangConfig(lang)));
|
||||
console.log(scriptMaker(await readLangConfig(program.lang)));
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
# 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:
|
||||
version "1.10.0"
|
||||
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
|
||||
|
|
Loading…
Reference in New Issue