diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..2221eb5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,29 @@ +name: Build and store YASM Frontend Image + +on: + push: + branches: + - task/** + - feature/** + - bug/** + pull_request: + branches: + - main + types: + - opened + - synchronize + - closed + +jobs: + build_push_image: + name: Building and storing YASM Frontend Docker Image + uses: necro-cloud/automations/.github/workflows/build-docker-image.yml@main + with: + dev_version_name: development + image_name: frontend + image_proper_name: YASM Frontend + build_path: . + repository: yasm + secrets: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..adbb99b --- /dev/null +++ b/Caddyfile @@ -0,0 +1,30 @@ +{ + # global options + admin off + persist_config off + auto_https off + # runtime logs + log { + format json + } +} + +# site block, listens on the $PORT environment variable +:{$PORT:3000} { + # access logs + log { + format json # set access log format to json mode + } + + # serve from the 'dist' folder (Vite builds into the 'dist' folder) + root * dist + + # enable gzipping responses + encode gzip + + # serve files from 'dist' + file_server + + # if path doesn't exist, redirect it to 'index.html' for client side routing + try_files {path} /index.html +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6c1a985 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# Build stage +FROM denoland/deno:latest as builder + +WORKDIR /app +COPY . . + +# Build the Solid App +RUN deno install && \ + deno task build + +# Production stage +FROM caddy + +WORKDIR /app + +# Copy the Caddyfile and format it +COPY Caddyfile ./ +RUN caddy fmt Caddyfile --overwrite + +# Copy the built static website +COPY --from=builder /app/dist ./dist + +# Port to be used for exposing the site +ENV PORT=5173 +EXPOSE 5173 + +CMD ["caddy", "run", "--config", "Caddyfile", "--adapter", "caddyfile"]