Skip to content

Commit

Permalink
Add Dockerfile for website (#910)
Browse files Browse the repository at this point in the history
  • Loading branch information
SapiensAnatis authored Jun 30, 2024
1 parent bf14aa6 commit 2cc3750
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 15 deletions.
12 changes: 10 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**/.classpath
**/.dockerignore
**/.env
**/.env*
**/.git
**/.gitignore
**/.project
Expand All @@ -27,4 +27,12 @@ LICENSE
README.md
PhotonPlugin/
**/*.Test/
**/logs
**/logs
**/.pnpm-store
**/build
**/mockServiceWorker.js
**/test-results
**/tests
**/dist
!Website/.env
!Website/.env.production
19 changes: 7 additions & 12 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ jobs:
TAG_REGEX="[\w]+?@v(.*)"
echo "Ref: ${{ inputs.ref }}"
echo "Tag: ${{ inputs.image-tag }}"
if [ ${{ inputs.image-tag }} != "undefined" ]
then
echo "tag=${{ inputs.image-tag }}" >> "$GITHUB_OUTPUT"
exit 0;
fi
if [ ${{ inputs.ref }} = "main" ]
then
echo "tag=latest" >> "$GITHUB_OUTPUT"
Expand All @@ -56,22 +56,17 @@ jobs:
echo "No image-tag provided and failed to derive image tag from ref"
exit 1;
fi
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x


- name: Build and push
uses: docker/build-push-action@v6
with:
Expand All @@ -80,4 +75,4 @@ jobs:
file: ${{ inputs.dockerfile }}
tags: ghcr.io/sapiensanatis/${{ inputs.image-name }}:${{ steps.derive-tag.outputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=max
18 changes: 18 additions & 0 deletions .github/workflows/publish-website.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Publish website

on:
push:
branches:
- main
paths:
- Website/**

jobs:
build:
name: Build
uses: ./.github/workflows/build.yaml
with:
ref: main
dockerfile: "Website/Dockerfile"
image-name: "dawnshard-website"
secrets: inherit
31 changes: 31 additions & 0 deletions Website/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM node:22.3.0-bookworm-slim AS base

EXPOSE 3000

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin
RUN npm install -g pnpm

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

WORKDIR /app
COPY ["Website/package.json", "Website/pnpm-lock.yaml", "./"]

FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
COPY ["Website/", "./"]
RUN echo "PUBLIC_ENABLE_MSW=false" >> ./.env.production
RUN pnpm run build

FROM base
COPY --from=prod-deps ["/app/node_modules", "./node_modules"]
COPY --from=build ["/app/build", "./"]

ENV NODE_ENV="production"

USER node
CMD ["node", "./index.js"]
2 changes: 1 addition & 1 deletion Website/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<link rel="icon" href="%sveltekit.assets%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Dawnshard</title>
%sveltekit.head%
Expand Down
Binary file added Website/static/favicon.ico
Binary file not shown.
Binary file removed Website/static/favicon.png
Binary file not shown.

0 comments on commit 2cc3750

Please sign in to comment.