Skip to content

Commit

Permalink
Add Makefile and apko config for a local dev-container environment (#…
Browse files Browse the repository at this point in the history
…1123)

Signed-off-by: Jamon Camisso <[email protected]>
  • Loading branch information
jamonation authored Nov 10, 2023
1 parent 3b08ba5 commit 59e6da6
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resources
.netlify
.hugo_build.lock
.DS_Store
.bash_history

# Editor / IDE config
.idea
Expand Down
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
54 changes: 54 additions & 0 deletions apko.yaml
Original file line number Diff line number Diff line change
@@ -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

8 changes: 8 additions & 0 deletions config/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions config/local-dev/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
canonifyURLs = false
baseURL = "http://localhost:8080"

0 comments on commit 59e6da6

Please sign in to comment.