Skip to content

Commit

Permalink
refactor: align with acdh app template
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst committed Oct 17, 2024
1 parent b168b86 commit 34285a0
Show file tree
Hide file tree
Showing 155 changed files with 4,450 additions and 2,662 deletions.
20 changes: 20 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Nuxt",
"image": "ghcr.io/acdh-oeaw/devcontainer-frontend:22",
"customizations": {
"vscode": {
"extensions": [
"bradlc.vscode-tailwindcss",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"lokalise.i18n-ally",
"mikestead.dotenv",
"ms-playwright.playwright",
"nuxt.mdc",
"stylelint.vscode-stylelint",
"vue.volar"
]
}
}
}
45 changes: 30 additions & 15 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,61 @@
node_modules/
.pnpm-store/

# nuxt.js
dist
.nuxt/
.nitro/
.output/

# logs
*.log

# non-public environment variables
.env
.env.local
.env.*.local

# caches
.eslintcache
.prettiercache
.stylelintcache
*.tsbuildinfo

# vercel
.vercel

# misc
.DS_Store
.idea/

# generated assets
/public/**/favicon.ico
/public/**/icon.svg
/public/**/android-chrome-192x192.png
/public/**/android-chrome-512x512.png
/public/**/apple-touch-icon.png
/public/**/app.webmanifest
/public/**/image.webp
# nuxt.js
dist
.data/
.nuxt/
.nitro/
.output/

# playwright
/blob-report/
/playwright/.cache/
/playwright-report/
/test-results/


## .dockerignore ##

# git
.git/
.gitattributes
.gitignore

# github
.github/

# vscode settings
.vscode/

# environment variables
.env
.env.*

# tests
playwright.config.ts
/e2e/
/test/

# misc
.editorconfig
9 changes: 0 additions & 9 deletions .env.example

This file was deleted.

31 changes: 31 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -------------------------------------------------------------------------------------------------
# environment variables
# -------------------------------------------------------------------------------------------------
# - public environment variables must be prefixed with `NUXT_PUBLIC_`.
# - when adding new environment variables, don't forget to also update the `runtimeConfig`
# section in `./nuxt.config.ts`.

# -------------------------------------------------------------------------------------------------
# app
# -------------------------------------------------------------------------------------------------
NUXT_PUBLIC_APP_BASE_URL="http://localhost:3000"
# imprint service
NUXT_PUBLIC_REDMINE_ID="21622"
# web crawlers
NUXT_PUBLIC_BOTS="disabled"

# -------------------------------------------------------------------------------------------------
# analytics
# -------------------------------------------------------------------------------------------------
# NUXT_PUBLIC_GOOGLE_SITE_VERIFICATION=
NUXT_PUBLIC_MATOMO_BASE_URL="https://matomo.acdh.oeaw.ac.at"
# NUXT_PUBLIC_MATOMO_ID=

# -------------------------------------------------------------------------------------------------
# typesense
# -------------------------------------------------------------------------------------------------
NUXT_PUBLIC_TYPESENSE_API_KEY="catYoetXCv1rTfAp5LzcQ6TKI48gkB13"
NUXT_PUBLIC_TYPESENSE_COLLECTION_PREFIX="viecpro_"
NUXT_PUBLIC_TYPESENSE_HOST="typesense.acdh-dev.oeaw.ac.at"
NUXT_PUBLIC_TYPESENSE_PORT="443"
NUXT_PUBLIC_TYPESENSE_PROTOCOL="https"
131 changes: 131 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: Build and deploy

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-build-deploy
cancel-in-progress: true

on:
workflow_call:
workflow_dispatch:

jobs:
env:
name: Generate environment variables
runs-on: ubuntu-latest
steps:
- name: Derive environment from git ref
id: environment
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
ENVIRONMENT="production"
APP_NAME_SUFFIX=""
elif [ "${{ github.ref }}" = "refs/heads/develop" ]; then
ENVIRONMENT="development"
APP_NAME_SUFFIX="-development"
elif [ "${{github.event_name}}" = "pull_request"]; then
ENVIRONMENT="pr/${{ github.event.pull_request.number }}"
APP_NAME_SUFFIX="-pr-${{ github.event.pull_request.number }}"
else
exit 1
fi
echo "ENVIRONMENT=$ENVIRONMENT" >> $GITHUB_OUTPUT
echo "APP_NAME_SUFFIX=$APP_NAME_SUFFIX" >> $GITHUB_OUTPUT
outputs:
environment: "${{ steps.environment.outputs.ENVIRONMENT }}"
app_name: "viecpro-frontend${{ steps.environment.outputs.APP_NAME_SUFFIX }}"
registry: ghcr.io
image: ${{ github.repository }}

vars:
name: Generate public url
needs: [env]
runs-on: ubuntu-latest
environment:
name: ${{ needs.env.outputs.environment }}
steps:
- name: Generate public URL
id: public_url
run: |
if [ -z "${{ vars.PUBLIC_URL }}" ]; then
PUBLIC_URL="https://${{ needs.env.outputs.app_name }}.${{ vars.KUBE_INGRESS_BASE_DOMAIN }}"
else
PUBLIC_URL="${{ vars.PUBLIC_URL }}"
fi
echo "PUBLIC_URL=$PUBLIC_URL" >> $GITHUB_OUTPUT
outputs:
public_url: ${{ steps.public_url.outputs.PUBLIC_URL }}

build:
name: Build and push docker image
needs: [env, vars]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
environment:
name: "${{ needs.env.outputs.environment }}"

steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ needs.env.outputs.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ needs.env.outputs.registry }}/${{ needs.env.outputs.image }}
tags: |
type=raw,value={{sha}}
type=ref,event=branch
# type=ref,event=pr
# type=semver,pattern={{version}}
# type=semver,pattern={{major}}.{{minor}}
# type=raw,value=latest

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"NUXT_PUBLIC_APP_BASE_URL=${{ needs.vars.outputs.public_url }}"
"NUXT_PUBLIC_BOTS=${{ vars.NUXT_PUBLIC_BOTS }}"
"NUXT_PUBLIC_GOOGLE_SITE_VERIFICATION=${{ vars.NUXT_PUBLIC_GOOGLE_SITE_VERIFICATION }}"
"NUXT_PUBLIC_MATOMO_BASE_URL=${{ vars.NUXT_PUBLIC_MATOMO_BASE_URL }}"
"NUXT_PUBLIC_MATOMO_ID=${{ vars.NUXT_PUBLIC_MATOMO_ID }}"
"NUXT_PUBLIC_REDMINE_ID=${{ vars.SERVICE_ID }}"
"NUXT_PUBLIC_TYPESENSE_API_KEY"="${{ vars.NUXT_PUBLIC_TYPESENSE_API_KEY }}"
"NUXT_PUBLIC_TYPESENSE_COLLECTION_PREFIX"="${{ vars.NUXT_PUBLIC_TYPESENSE_COLLECTION_PREFIX }}"
"NUXT_PUBLIC_TYPESENSE_HOST"="${{ vars.NUXT_PUBLIC_TYPESENSE_HOST }}"
"NUXT_PUBLIC_TYPESENSE_PORT"="${{ vars.NUXT_PUBLIC_TYPESENSE_PORT }}"
"NUXT_PUBLIC_TYPESENSE_PROTOCOL"="${{ vars.NUXT_PUBLIC_TYPESENSE_PROTOCOL }}"
cache-from: type=ghax
cache-to: type=gha,mode=max

deploy:
name: Deploy docker image
needs: [env, vars, build]
uses: acdh-oeaw/gl-autodevops-minimal-port/.github/workflows/deploy.yml@main
secrets: inherit
with:
environment: ${{ needs.env.outputs.environment }}
DOCKER_TAG: ${{ needs.env.outputs.registry }}/${{ needs.env.outputs.image }}
APP_NAME: "${{ needs.env.outputs.app_name }}"
APP_ROOT: "/"
SERVICE_ID: "${{ vars.SERVICE_ID }}"
PUBLIC_URL: "${{ needs.vars.outputs.public_url }}"
default_port: "3000"
32 changes: 0 additions & 32 deletions .github/workflows/playwright.yml

This file was deleted.

Loading

0 comments on commit 34285a0

Please sign in to comment.