Build webserver using ko-build

This commit is contained in:
Elara 2023-08-08 14:44:47 -07:00
parent 3fab794c13
commit ca91974429
6 changed files with 14 additions and 27 deletions

View File

@ -8,7 +8,9 @@ The containers are stored on my gitea instance, so you can pull them like this:
docker pull gitea.elara.ws/elara6331/golang:latest docker pull gitea.elara.ws/elara6331/golang:latest
``` ```
Some of the images use [ko.build](https://github.com/ko-build/ko)
### Images ### Images
- `golang`: An alpine-based image with Go installed - `golang`: An alpine-based image with Go installed
- `webserver`: A very simple webserver - `webserver`: A very simple webserver

View File

@ -1,4 +0,0 @@
FROM busybox:latest
COPY webserver /usr/bin/webserver
RUN mkdir /html
ENTRYPOINT webserver

View File

@ -2,4 +2,6 @@
The [webserver image](https://gitea.elara.ws/Elara6331/-/packages/container/webserver/latest) is a very simple webserver that serves its `/html` directory and logs requests. It doesn't have any TLS capabilities or anything like that, it just serves some static files and does nothing else. The [webserver image](https://gitea.elara.ws/Elara6331/-/packages/container/webserver/latest) is a very simple webserver that serves its `/html` directory and logs requests. It doesn't have any TLS capabilities or anything like that, it just serves some static files and does nothing else.
You can change the address it listens on using the `WEBSERVER_ADDR` environment variable. You can change the address it listens on using the `WEBSERVER_ADDR` environment variable.
This image uses [ko.build](https://ko.build)

View File

@ -1,12 +1,7 @@
#!/bin/bash #!/bin/bash
if [[ $# == 0 ]]; then pushd cmd
echo "Usage: $0 <arch>" KO_DOCKER_REPO=gitea.elara.ws/elara6331 ko build -B \
exit 1 --platform=linux/amd64,linux/arm64,linux/riscv64 \
fi --sbom=none
popd
GOOS=linux GOARCH=$1 go build -o webserver ./cmd/main.go
docker login gitea.elara.ws
docker build . -t "gitea.elara.ws/elara6331/webserver:$1"
docker push "gitea.elara.ws/elara6331/webserver:$1"

3
webserver/cmd/go.mod Normal file
View File

@ -0,0 +1,3 @@
module webserver
go 1.21.0

View File

@ -1,11 +0,0 @@
#!/bin/bash
tag="$1"
tag="${tag:=latest}"
docker login gitea.elara.ws
docker manifest create "gitea.elara.ws/elara6331/webserver:$tag" \
--amend gitea.elara.ws/elara6331/webserver:amd64 \
--amend gitea.elara.ws/elara6331/webserver:arm64 \
--amend gitea.elara.ws/elara6331/webserver:riscv64
docker manifest push "gitea.elara.ws/elara6331/webserver:$tag"