4
0

added example

This commit is contained in:
Benjamin Böhmke 2019-11-12 21:02:43 +01:00
parent e462a26e19
commit 6893cd3495
6 changed files with 38 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea/

3
example/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
app
alpine*.img*
flash.sh

5
example/build_image.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
docker run --rm -v "$PWD":/work -w /work -e GOOS=linux -e GOARCH=arm -e GOARM=5 golang:1.13-alpine go build -v -o ./app .
docker run --rm -it -v "$PWD":/input -v $PWD:/output bboehmke/raspi-alpine-builder

6
example/image.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
cp ${INPUT_PATH}/app ${ROOTFS_PATH}/usr/bin/test_app
cp ${INPUT_PATH}/init.sh ${ROOTFS_PATH}/etc/init.d/test_app
chroot_exec rc-update add test_app default

13
example/init.sh Executable file
View File

@ -0,0 +1,13 @@
#!/sbin/openrc-run
command="/usr/bin/test_app"
pidfile="/var/run/test_app.pid"
command_args=""
command_background=true
depend() {
use logger dns
need net
after firewall
}

10
example/main.go Normal file
View File

@ -0,0 +1,10 @@
package main
import "net/http"
func main() {
http.HandleFunc("/", func(writer http.ResponseWriter, _ *http.Request) {
writer.Write([]byte("It works!"))
})
http.ListenAndServe(":8080", nil)
}