Docker support & image
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Ada 2024-02-17 22:02:11 +01:00
parent abede92f3b
commit b8bf9de3ec
Signed by: ada
GPG key ID: 6A7F898157C6DE6E
5 changed files with 77 additions and 0 deletions

17
.woodpecker/build.yaml Normal file
View file

@ -0,0 +1,17 @@
steps:
- name: publish_image
image: woodpeckerci/plugin-docker-buildx
settings:
repo: git.gnous.eu/${CI_REPO_OWNER}/wiki
dockerfile: docker/Dockerfile
platforms: linux/amd64
registry: https://git.gnous.eu
tag: ${CI_COMMIT}
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
event: push

21
docker/Dockerfile Normal file
View file

@ -0,0 +1,21 @@
FROM golang:1.22 as build
WORKDIR /build
COPY . .
RUN wget https://github.com/rust-lang/mdBook/releases/download/v0.4.37/mdbook-v0.4.37-x86_64-unknown-linux-gnu.tar.gz
RUN tar xvf mdbook-v0.4.37-x86_64-unknown-linux-gnu.tar.gz
RUN ./mdbook build
RUN CGO_ENABLED=0 go build -ldflags "-w -s" docker/serve.go
FROM gcr.io/distroless/static-debian12:nonroot
WORKDIR /app
COPY --from=build /build/serve .
COPY --from=build /build/book/ static/
EXPOSE 3000
CMD ["/app/serve"]

View file

@ -0,0 +1,12 @@
version: "3"
services:
www:
build:
context: ../
dockerfile: docker/Dockerfile
restart: always
container_name: www
ports:
- "3000:3000"

View file

@ -0,0 +1,18 @@
version: "3"
networks:
plakken:
external: false
volumes:
redis:
driver: local
services:
server:
image: git.gnous.eu/gnouseu/wiki:latest
restart: always
container_name: plakken
read_only: true
ports:
- "3000:3000"

9
docker/serve.go Normal file
View file

@ -0,0 +1,9 @@
package main
import "net/http"
func main() {
fs := http.FileServer(http.Dir("./static"))
http.Handle("GET /", fs)
http.ListenAndServe(":3000", nil)
}