Infrastructure go brrr

This commit is contained in:
Radon Rosborough 2021-07-04 17:13:59 +00:00
parent 7da6e0a5f7
commit 719b16f3c0
8 changed files with 63 additions and 17 deletions

View File

@ -224,11 +224,12 @@ upload: # L=<lang> T=<type> : Upload .deb to S3
aws s3 cp $(BUILD)/$(DEB) $(S3_DEB) aws s3 cp $(BUILD)/$(DEB) $(S3_DEB)
hash="$$(dpkg-deb -f $(BUILD)/$(DEB) Riju-Script-Hash | grep .)"; aws s3 cp - "$(S3_HASH)/$${hash}" < /dev/null hash="$$(dpkg-deb -f $(BUILD)/$(DEB) Riju-Script-Hash | grep .)"; aws s3 cp - "$(S3_HASH)/$${hash}" < /dev/null
config: # Generate deployment config file deploy-config: # Generate deployment config file
node tools/generate-deploy-config.js node tools/generate-deploy-config.js
deploy: # Upload deployment config to S3 deploy: deploy-config # Upload deployment config to S3 and update ASG instances
aws s3 cp $(BUILD)/config.json $(S3_CONFIG) aws s3 cp $(BUILD)/config.json $(S3_CONFIG)
tools/force-update-asg.bash
### Infrastructure ### Infrastructure

View File

@ -312,9 +312,9 @@ export class Session {
this.send({ event: "terminalClear" }); this.send({ event: "terminalClear" });
let cmdline; let cmdline;
if (code) { if (code) {
cmdline = run; cmdline = `set +e; ${run}`;
if (compile) { if (compile) {
cmdline = `( ${compile} ) && ( set +e; ${run} )`; cmdline = `( ${compile} ) && ( ${run} )`;
} }
} else if (repl) { } else if (repl) {
cmdline = repl; cmdline = repl;

View File

@ -7,7 +7,7 @@ WORKDIR /src
COPY Makefile ./ COPY Makefile ./
COPY system ./system/ COPY system ./system/
RUN make system RUN make system UNPRIVILEGED=1
COPY package.json yarn.lock ./ COPY package.json yarn.lock ./
RUN yarn install RUN yarn install

View File

@ -38,25 +38,37 @@ input: |
output: | output: |
base.List.reverse base.List.reverse
# runProg implementation courtesy of Robert Offner from Unison Slack!
main: "main.u" main: "main.u"
template: | template: |
use io use io
main : '{IO} () runProg: '{IO, Exception} a -> '{IO} ()
main = 'let runProg f = 'let
printErr err = match err with
Failure _ errMsg _ -> handle putBytes (stdHandle StdErr) (toUtf8 errMsg) with cases
{raise _ -> _} -> ()
{_} -> ()
match catch f with
Left err -> printErr err
Right _ -> ()
main: '{IO} ()
main = runProg 'let
printLine "Hello, world!" printLine "Hello, world!"
createEmpty: ""
run: | run: |
echo "Type 'run main' to run the code." unison -codebase . run.file main.u main
echo "Type 'load main.u' at the repl prompt to bring variables into scope."
unison -codebase . unison -codebase .
helloInput: |
DELAY: 3
run main
scope: scope:
code: | code: |
x = 123 * 234 x = 123 * 234
input: | input: |
DELAY: 3
load main.u
DELAY: 3 DELAY: 3
add x add x
DELAY: 3 DELAY: 3

View File

@ -33,8 +33,8 @@ const blueName = "riju-app-blue"
const greenName = "riju-app-green" const greenName = "riju-app-green"
type deploymentConfig struct { type deploymentConfig struct {
LangImageTags map[string]string `json:"langImageTags"`
AppImageTag string `json:"appImageTag"` AppImageTag string `json:"appImageTag"`
LangImageTags map[string]string `json:"langImageTags"`
} }
type supervisorConfig struct { type supervisorConfig struct {

View File

@ -18,7 +18,7 @@ for src in system/src/*.c; do
out="${src/src/out}" out="${src/src/out}"
out="${out/.c}" out="${out/.c}"
verbosely clang -Wall -Wextra -Werror -std=c11 "${src}" -o "${out}" verbosely clang -Wall -Wextra -Werror -std=c11 "${src}" -o "${out}"
if [[ "${out}" == *-privileged ]]; then if [[ "${out}" == *-privileged && -z "${UNPRIVILEGED:-}" ]]; then
verbosely sudo chown root:riju "${out}" verbosely sudo chown root:riju "${out}"
verbosely sudo chmod a=,g=rx,u=rwxs "${out}" verbosely sudo chmod a=,g=rx,u=rwxs "${out}"
fi fi

View File

@ -250,9 +250,22 @@ async function getLanguageTestArtifact({ lang }) {
}; };
} }
async function getDeployArtifact(langs) { async function getDeployReadyArtifact(langs) {
return { return {
name: `deploy:prod`, name: `deploy:ready`,
dependencies: ["image:app"]
.concat(langs.map((lang) => `image:lang-${lang}`))
.concat(langs.map((lang) => `test:lang-${lang}`)),
publishTarget: true,
publishToRegistry: async () => {
await runCommand(`make deploy-config`);
},
};
}
async function getDeployLiveArtifact(langs) {
return {
name: `deploy:live`,
dependencies: ["image:app"] dependencies: ["image:app"]
.concat(langs.map((lang) => `image:lang-${lang}`)) .concat(langs.map((lang) => `image:lang-${lang}`))
.concat(langs.map((lang) => `test:lang-${lang}`)), .concat(langs.map((lang) => `test:lang-${lang}`)),
@ -298,7 +311,8 @@ async function getDepGraph() {
artifacts.push(await getLanguageTestArtifact({ lang: lang })); artifacts.push(await getLanguageTestArtifact({ lang: lang }));
} }
artifacts.push(await getImageArtifact({ tag: "app" })); artifacts.push(await getImageArtifact({ tag: "app" }));
artifacts.push(await getDeployArtifact(langs)); artifacts.push(await getDeployReadyArtifact(langs));
artifacts.push(await getDeployLiveArtifact(langs));
return { informationalDependencies, artifacts }; return { informationalDependencies, artifacts };
} }

View File

@ -1,10 +1,29 @@
import { promises as fs } from "fs"; import { promises as fs } from "fs";
import url from "url"; import url from "url";
import { Command } from "commander";
import { getLangs } from "../lib/yaml.js";
import { getLocalImageLabel } from "./docker-util.js";
// Get the contents of the JSON file that will be written to S3 in // Get the contents of the JSON file that will be written to S3 in
// order to deploy Riju. // order to deploy Riju.
async function getDeployConfig() { async function getDeployConfig() {
// TODO const langs = await getLangs();
const langImageTags = Object.fromEntries(
await Promise.all(
langs.map(async (lang) => [
lang,
`lang-${lang}-` +
(await getLocalImageLabel(`riju:lang-${lang}`, "riju.image-hash")),
])
)
);
const appImageTag = await getLocalImageLabel(`riju:app`, "riju.image-hash");
return {
appImageTag,
langImageTags,
}
} }
// Parse command-line arguments, run main functionality, and exit. // Parse command-line arguments, run main functionality, and exit.