diff --git a/Makefile b/Makefile index 6dddc22..5d5405b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: synchronize synchronize: - @bash ./scripts/synchronize.sh + @sh ./scripts/synchronize.sh .PHONY: website-install-depenencies website-install-depenencies: diff --git a/docker-compose.yaml b/docker-compose.yaml index 8297742..fd4532e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,5 +1,20 @@ version: '3.9' services: + website: + build: + context: . + dockerfile: ./website/Dockerfile + args: + - HUGO_BASEURL=http://localhost:5001 + restart: unless-stopped + ports: + - "5001:80" + labels: + - "traefik.enable=true" + # The domain the service will respond to + - "traefik.http.routers.demo.rule=Host(`perses.dev`)" + - "traefik.http.routers.demo.tls.certresolver=myresolver" + demo: image: "docker.io/persesdev/perses:main-2023-12-19-6a7acd38-distroless" ports: diff --git a/scripts/synchronize.sh b/scripts/synchronize.sh index be309f2..6369d6c 100755 --- a/scripts/synchronize.sh +++ b/scripts/synchronize.sh @@ -4,7 +4,7 @@ ROOT_DIR=$(pwd) TAG_FILTER_RE="v(0|[1-9]\d*)\.([1-9]\d*).0" GREP=$(which ggrep 2>/dev/null || which grep) BASE_OUTPUT_DIR=$ROOT_DIR/website/content/docs -REPOS_DIR=$ROOT_DIR/repos/ +REPOS_DIR=$ROOT_DIR/repos MDOX_CONFIG=".mdox.yaml" PERSES_REPO_URL="https://github.com/perses/perses" @@ -19,7 +19,7 @@ rm -rf $REPOS_DIR && mkdir $REPOS_DIR ## This is useful for local development ## developers can set the USE_LOCAL_REPOSITORIES environment variable ## to use local repositories instead of cloning them from GitHub -if [[ -z "$USE_LOCAL_REPOSITORIES" ]]; then +if [ -z "$USE_LOCAL_REPOSITORIES" ]; then git clone $PERSES_REPO_URL -b main --depth 1 $PERSES_REPO_DIR else # Check the operating system @@ -87,7 +87,7 @@ result=$($ROOT_DIR/scripts/semver_compare.sh $release_number "0.42.0") # We only care about the versions greater than 0.42.0 # Because the documentation for the versions less than 0.42.0 is not available -if [[ $result -eq 0 ]]; then +if [ $result -eq 0 ]; then continue fi diff --git a/website/Dockerfile b/website/Dockerfile new file mode 100644 index 0000000..6819ef8 --- /dev/null +++ b/website/Dockerfile @@ -0,0 +1,27 @@ +FROM golang:1.21 as synchronizer + +COPY ./website ./website +COPY ./scripts ./scripts +COPY Makefile . +COPY .mdox.yaml . + +RUN go install github.com/bwplotka/mdox@latest +RUN apt update && apt install -y git make + +RUN make synchronize + +FROM hugomods/hugo:exts as builder + +ARG HUGO_BASEURL= +ENV HUGO_BASEURL=${HUGO_BASEURL} + +COPY --from=synchronizer /go/website . + +RUN npm install --ignore-scripts + +RUN hugo --minify --gc --cleanDestinationDir + +FROM hugomods/hugo:nginx + +# Copy the generated files to keep the image as small as possible. +COPY --from=builder /src/public /site