From 452ff5f409ca3256e38270a987c8b4c5276a2b78 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Tue, 22 Dec 2020 15:56:21 -0800 Subject: [PATCH] Create some AWS resources --- .gitignore | 1 + Makefile | 28 +++++++++++++---- README.md | 50 ++++++++++++++++++++++++++++++ {builder => src/packager}/build.js | 0 {builder => src/packager}/debug.js | 0 tf/infra.tf | 32 +++++++++++++++++++ 6 files changed, 105 insertions(+), 6 deletions(-) create mode 100644 README.md rename {builder => src/packager}/build.js (100%) rename {builder => src/packager}/debug.js (100%) create mode 100644 tf/infra.tf diff --git a/.gitignore b/.gitignore index b01cda1..5adbbb6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.log +.env debs node_modules work diff --git a/Makefile b/Makefile index 92834f2..d3d7639 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,26 @@ export PATH := bin:$(PATH) debug: node builder/build.js python -.PHONY: build-image -build-image: - docker build . -f docker/Dockerfile.build -t riju:build +.PHONY: packaging-image +packaging-image: + docker build . -f docker/packaging/Dockerfile -t riju:packaging -.PHONY: build-shell -build-shell: build-image - docker run -it --rm -v $(PWD):/src riju:build +.PHONY: runtime-image +runtime-image: + docker build . -f docker/runtime/Dockerfile -t riju:runtime + +.PHONY: app-image +app-image: + docker build . -f docker/app/Dockerfile -t riju:app + +.PHONY: packaging-shell +packaging-shell: + docker run -it --rm -v $(PWD):/src riju:packaging + +.PHONY: runtime-shell +runtime-shell: + docker run -it --rm -v $(PWD):/src riju:runtime + +.PHONY: pkg +pkg: + node src/packager/main.js --lang $(LANG) diff --git a/README.md b/README.md new file mode 100644 index 0000000..ebe9aa0 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# Riju + +For now, this README just has some miscellaneous notes about the build +architecture that I'm planning to set up. Later, it will be converted +back into a proper README. + +Steps to build Riju from scratch locally: + +* Build the packaging Docker image. +* Generate a Debian package for each language. +* Build the runtime Docker image. +* For each language, install its Debian package into a fresh copy of + the runtime Docker image and run its tests. +* Install every language's Debian package into a single copy of the + runtime Docker image and run all the tests. + +Build artifacts: + +* Packaging image +* Runtime image +* Debian packages +* Application image + +Steps to build Riju from cache locally: + +* *To run:* Pull application image. +* *To build application image:* Pull runtime image and all Debian + packages. +* *To build Debian packages:* Pull packaging image. +* *To build runtime image:* Build from scratch. +* *To build packaging image:* Build from scratch. + +To manipulate published artifacts we basically want to do atomic +updates which keep the integration tests passing. Possible operations: + +* *Rebuild packaging image:* This can be done at any time. +* *Rebuild runtime image:* Rebuild application image and verify + integration tests are still passing. Do not rebuild any Debian + packages. +* *Rebuild Debian package:* Verify unit tests are passing. Rebuild + application image and verify integration tests are still passing. If + rebuilding multiple Debian packages, then we can run the integration + tests only once. If rebuilding enough Debian packages, the + probability that at least one will fail is very high. We can then + trigger a more targeted update. This process could be automated. +* *CI:* Rebuild packaging and runtime images if needed. Rebuild Debian + packages for any changed languages. Fetch everything unchanged from + registry. Rebuild application image and verify integration tests are + still passing. If yes and operating on main branch, publish all + artifacts and deploy. diff --git a/builder/build.js b/src/packager/build.js similarity index 100% rename from builder/build.js rename to src/packager/build.js diff --git a/builder/debug.js b/src/packager/debug.js similarity index 100% rename from builder/debug.js rename to src/packager/debug.js diff --git a/tf/infra.tf b/tf/infra.tf new file mode 100644 index 0000000..466eaf9 --- /dev/null +++ b/tf/infra.tf @@ -0,0 +1,32 @@ +terraform { + backend "remote" { + organization = "riju" + workspaces { + name = "riju" + } + } + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 2.70" + } + } +} + +provider "aws" { + profile = "default" + region = "us-west-1" +} + +resource "aws_s3_bucket" "riju_debs" { + bucket = "riju-debs" + acl = "private" + tags = { + Terraform = "Managed by Terraform" + } +} + +resource "aws_ecr_repository" "riju_app" { + name = "riju-app" + image_tag_mutability = "IMMUTABLE" +}