From ef9f0139e5f55a5d45409e213ddc49e7d6c0ea92 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sat, 26 Oct 2024 22:47:34 +0000 Subject: [PATCH] Test this website with score-compose Signed-off-by: Mathieu Benoit --- .github/workflows/pull-request.yml | 14 +++++++++++++- .gitignore | 6 +++++- Dockerfile | 16 ++++++++++++++++ README.md | 14 ++++++++++++++ score.yaml | 20 ++++++++++++++++++++ 5 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 score.yaml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 994155eb..c8d85472 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -19,4 +19,16 @@ jobs: - run: npm install -g yarn - run: yarn install - run: yarn run hugo - - run: yarn run dprint check \ No newline at end of file + - run: yarn run dprint check + - uses: score-spec/setup-score@v3 + with: + file: score-compose + token: ${{ secrets.GITHUB_TOKEN }} + version: 'latest' + - run: | + score-compose init --no-sample + score-compose generate score.yaml --build main=. + - run: | + docker compose up --build -d + - run: | + curl $(score-compose resources get-outputs dns.default#score-docs.dns --format '{{ .host }}:8080/docs/') \ No newline at end of file diff --git a/.gitignore b/.gitignore index 192eecf7..b632c4f2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,8 @@ package-lock.json .hugo_build.lock .cspell/ .vscode/ltex.dictionary.en-US.txt -./static/_pagefind \ No newline at end of file +./static/_pagefind +.score-compose/state.yaml +.score-compose/zz-default.provisioners.yaml +.score-compose/mounts/routing-QXKXWL/nginx.conf +compose.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..7eba4129 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# We use golang because hugo depends on Go as it's module downloader +FROM golang:alpine +# We then install shared libs and dynamic linking dependencies +RUN apk add --no-cache gcc g++ musl-dev git yarn gcompat npm + +COPY . /src +WORKDIR /src + +# Install all the packages +RUN yarn install + +# Do an initial hugo build +RUN yarn hugo --verbose + +# Run the hugo server at launch +CMD [ "yarn", "hugo", "server", "--themesDir", "../..", "--disableFastRender", "--renderToMemory", "--bind", "0.0.0.0" ] \ No newline at end of file diff --git a/README.md b/README.md index ad21a0ef..c49468d6 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ For information on Score's style guide see the [Style guide](styles/style-guide. ### Running the website locally +#### `yarn` + We use `yarn` (for MacOS: `brew install yarn`) as a package manager to ensure the versions of Hugo and associated tools are up to date. All commands that execute those tools are prefixed with `yarn run` or are aliased in the `package.json` file. To install the packages: @@ -27,6 +29,18 @@ yarn run hugo server And then view it at . +#### `score-compose` + +You can [install `score-compose`](https://docs.score.dev/docs/score-implementation/score-compose/installation/) and then build and run this hugo website as a container: +``` +score-compose init --no-sample +score-compose generate score.yaml --build main=. + +docker compose up --build -d + +curl $(score-compose resources get-outputs dns.default#score-docs.dns --format '{{ .host }}:8080/docs/') +``` + ### Deployment This site is currently deployed through Github Pages with a CNAME directing `docs.score.dev` to `score-spec.github.io`. The DNS configuration is managed by Humanitec. diff --git a/score.yaml b/score.yaml new file mode 100644 index 00000000..f6f53783 --- /dev/null +++ b/score.yaml @@ -0,0 +1,20 @@ +apiVersion: score.dev/v1b1 +metadata: + name: score-docs +containers: + main: + image: . +resources: + dns: + type: dns + route: + type: route + params: + host: ${resources.dns.host} + path: / + port: 8080 +service: + ports: + tcp: + port: 8080 + targetPort: 8080 \ No newline at end of file