Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kagameow authored Apr 12, 2024
0 parents commit b80ea56
Show file tree
Hide file tree
Showing 45 changed files with 3,317 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/engine/reference/builder/#dockerignore-file

**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.cache
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/build
**/dist
LICENSE
README.md
15 changes: 15 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')

module.exports = {
root: true,
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript',
'@vue/eslint-config-prettier/skip-formatting'
],
parserOptions: {
ecmaVersion: 'latest'
}
}
73 changes: 73 additions & 0 deletions .github/workflows/build_web.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build web

on:
workflow_call:

env:
REGISTRY: ghcr.io

jobs:
build_web:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Helm
uses: azure/setup-helm@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64, linux/arm64

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

- name: Make versions
run: |
chmod +x ./tools/version.sh
./tools/version.sh "${{ github.sha }}" "${{ env.REGISTRY }}/${{ vars.DOCKER_IMAGE_NAME }}"
echo "APP_VERSION=$(cat "./VERSION")" >> $GITHUB_ENV
echo "DOCKER_IMAGES=$(cat "./DOCKER_IMAGES")" >> $GITHUB_ENV
echo "DOCKER_TAGS=$(cat "./VERSION_DOCKER")" >> $GITHUB_ENV
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ vars.DOCKER_IMAGE_NAME }}
tags: ${{ env.DOCKER_TAGS }}

- name: Build and push docker image
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ env.DOCKER_IMAGES }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64, linux/arm64

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Create a github release
run: gh release create "${{ env.APP_VERSION }}"
env:
GH_TOKEN: ${{ github.token }}

- name: Publish Helm charts
uses: stefanprodan/helm-gh-pages@master
with:
token: ${{ github.token }}
target_dir: "./helm-charts/"
22 changes: 22 additions & 0 deletions .github/workflows/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build and push docker image

on:
push:
branches:
- '**'
tags:
- '**'
paths-ignore:
- 'releases/**'
pull_request:
branches:
- '**'
workflow_dispatch:

jobs:
build:
permissions:
contents: write
packages: write
secrets: inherit
uses: ./.github/workflows/build_web.yaml
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

*.tsbuildinfo
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"singleQuote": true,
"singleAttributePerLine": true
}
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"Vue.volar",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# syntax=docker/dockerfile:1

# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/engine/reference/builder/

ARG NODE_VERSION=20.12.0

################################################################################
# Use node image for base image for all stages.
FROM node:${NODE_VERSION}-alpine as base

# Set working directory for all build stages.
WORKDIR /usr/src/app


################################################################################
# Create a stage for installing production dependecies.
FROM base as deps

# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.yarn to speed up subsequent builds.
# Leverage bind mounts to package.json and yarn.lock to avoid having to copy them
# into this layer.
RUN corepack enable
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \
--mount=type=cache,id=pnpm,target=/pnpm/store \
pnpm install --prod --frozen-lockfile

################################################################################
# Create a stage for building the application.
FROM deps as build

# Download additional development dependencies before building, as some projects require
# "devDependencies" to be installed to build. If you don't need this, remove this step.
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \
--mount=type=cache,id=pnpm,target=/pnpm/store \
pnpm install --frozen-lockfile

# Copy the rest of the source files into the image.
COPY . .
# Run the build script.
RUN pnpm run build

################################################################################
FROM nginx:stable-alpine as nginx

COPY --from=build /usr/src/app/dist /usr/share/nginx/html

COPY conf/nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

CMD [ "nginx", "-g", "daemon off;" ]

79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Default Vue 3 + Vite + TypeScript Template
Vite + Vue template with TypeScript
- [ESLint](https://eslint.org/) is used for linting and [Prettier](https://prettier.io/) is used for code formatting.
- [Vue Router](https://router.vuejs.org/) is included for multi-page apps, remove it if not needed.
- [Pinia](https://pinia.esm.dev/) is included for state management, remove it if not needed.
- Helm charts for Kubernetes are also included.
- [PostCSS](https://postcss.org/) is used for CSS processing and includes CSS Nesting support plugin.

## Recommended IDE Setup

[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
JetBrains IDEs are also recommended, but make sure to use Vue Language Server (Volar).
If you use Vim or Emacs, you probably already know what you're doing.

## Type Support for `.vue` Imports in TS

TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.

## Customize Vite configuration

See [Vite Configuration Reference](https://vitejs.dev/config/).

## Dockerfile

Dockerfile is included for building a Docker [NGINX](https://nginx.com) image with the app production build. Basic configuration is included in `conf` folder, but it's recommended to customize it for your needs.

## GitHub Actions

GitHub Actions workflow is included for building Docker image and pushing it to GitHub Container Registry,
and subsequently [publishing Helm charts to GitHub Pages](https://helm.sh/docs/topics/chart_repository/).

## Project Setup

Node 20 or higher is required.
Node installation is recommended via [nvm](https://github.com/nvm-sh/nvm).

If you are interested in GitHub Actions workflow that works with this project, you need to set up GitHub Variables for your repository at `https://github.com/<workspace>/<project>/settings/variables/actions`:
- `DOCKER_IMAGE_NAME` - The name of the Docker image for uploading to the repository. Format: `<workspace>/<project>`

Also `gh-pages` branch should be created for publishing Helm charts. To create empty gh-pages branch, run the following commands:

```sh
git switch --orphan gh-pages
git commit --allow-empty -m "gh-pages branch created"
git push -u origin gh-pages
```

Project is set up with [pnpm](https://pnpm.io/).
Also, project is [Corepack](https://github.com/nodejs/corepack)-ready, it's usually already included in modern Node.js versions.
So, there is no need to install `pnpm` globally, just run `corepack enable` and `pnpm install`.

```sh
corepack enable
pnpm install
```

### Compile and Hot-Reload for Development

```sh
pnpm dev
```

### Type-Check, Compile and Minify for Production

```sh
pnpm build
```

### Lint with [ESLint](https://eslint.org/)

```sh
pnpm lint
```

### Format with [Prettier](https://prettier.io/)

```sh
pnpm format
```
23 changes: 23 additions & 0 deletions charts/app/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions charts/app/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: app
description: A frontend web service template for reuse.
type: application
version: ""
appVersion: ""
Loading

0 comments on commit b80ea56

Please sign in to comment.