From 59e6da68bcb29ad31063269da524709f9cf7d4aa Mon Sep 17 00:00:00 2001 From: Jamon Camisso Date: Fri, 10 Nov 2023 10:08:41 -0500 Subject: [PATCH] Add Makefile and apko config for a local dev-container environment (#1123) Signed-off-by: Jamon Camisso --- .gitignore | 1 + Makefile | 31 +++++++++++++++++++++ apko.yaml | 54 ++++++++++++++++++++++++++++++++++++ config/entrypoint.sh | 8 ++++++ config/local-dev/config.toml | 2 ++ 5 files changed, 96 insertions(+) create mode 100644 Makefile create mode 100644 apko.yaml create mode 100755 config/entrypoint.sh create mode 100644 config/local-dev/config.toml diff --git a/.gitignore b/.gitignore index b236800863..78ec044f96 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ resources .netlify .hugo_build.lock .DS_Store +.bash_history # Editor / IDE config .idea diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..6bc459c3b7 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +cfg?=apko.yaml +arch := $(shell uname -m) + +.PHONY: apko-build dev-container +apko-build: + docker run --rm -v $$PWD:/work -it cgr.dev/chainguard/apko:latest build \ + --arch $(arch) \ + /work/$(cfg) academy.local /work/academy.tar + docker load < academy.tar + rm academy.tar + +dev-container: +ifeq ("$(arch)","x86_64") + docker run --rm \ + -v $$PWD/config/entrypoint.sh:/entrypoint.sh \ + -v $$PWD/public:/usr/share/nginx/html \ + -v $$PWD/nginx.conf:/etc/nginx/nginx.conf \ + -v $$PWD:/home/inky/ \ + -p 8080:8080 -p 1313:1313 \ + -it --user root \ + academy.local:latest-amd64 +else + docker run --rm \ + -v $$PWD/config/entrypoint.sh:/entrypoint.sh \ + -v $$PWD/public:/usr/share/nginx/html \ + -v $$PWD/nginx.conf:/etc/nginx/nginx.conf \ + -v $$PWD:/home/inky/ \ + -p 8080:8080 -p 1313:1313 \ + -it --user root \ + academy.local:latest-$arch +endif diff --git a/apko.yaml b/apko.yaml new file mode 100644 index 0000000000..aef091b457 --- /dev/null +++ b/apko.yaml @@ -0,0 +1,54 @@ +contents: + repositories: + - https://packages.wolfi.dev/os + keyring: + - https://packages.wolfi.dev/os/wolfi-signing.rsa.pub + packages: + - bash + - ca-certificates-bundle + - coreutils + - hugo-extended + - nano + - nginx + - nodejs + - npm + - tmux + - vim + - wolfi-base + +accounts: + groups: + - groupname: inky + gid: 2000 + users: + - username: inky + uid: 2000 + run-as: inky + +work-dir: /home/inky + +paths: + - path: /var/lib/nginx + type: directory + uid: 2000 + gid: 2000 + permissions: 0o755 + recursive: true + - path: /var/lib/nginx/tmp + uid: 2000 + gid: 2000 + type: directory + # Wide permissions required for running with tmpfs. Seems to be related to Docker bug https://github.com/moby/moby/issues/40881 + permissions: 0o777 + recursive: true + - path: /var/run + uid: 2000 + gid: 2000 + type: directory + # Wide permissions required for running with tmpfs. Seems to be related to Docker bug https://github.com/moby/moby/issues/40881 + permissions: 0o777 + recursive: false + +entrypoint: + command: /bin/bash /entrypoint.sh + diff --git a/config/entrypoint.sh b/config/entrypoint.sh new file mode 100755 index 0000000000..9ca4b6b55a --- /dev/null +++ b/config/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +su - inky -s /bin/bash -c '/usr/sbin/nginx -c /etc/nginx/nginx.conf -e /dev/stderr -g "daemon on;" > /dev/null 2>&1' +printf "\nWelcome to the Academy development environment!\n\n" +export PS1="[academy] ❯ " +export GOPATH="/root/.cache/go" +export CGO_ENABLED=0 +bash -i diff --git a/config/local-dev/config.toml b/config/local-dev/config.toml new file mode 100644 index 0000000000..3496452da2 --- /dev/null +++ b/config/local-dev/config.toml @@ -0,0 +1,2 @@ +canonifyURLs = false +baseURL = "http://localhost:8080"