diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6754800 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,18 @@ +node_modules + +dist + +.git +.gitignore + +.env.local + +# IDE settings +.idea +.vscode + +yarn-error.log* + +# Operating system files +.DS_Store +Thumbs.db \ No newline at end of file diff --git a/.env b/.env new file mode 100644 index 0000000..663c88d --- /dev/null +++ b/.env @@ -0,0 +1,5 @@ +VITE_TITLE=Vite Insee Starter +VITE_DESCRIPTION=Vite + TypeScript + React + react-dsfr + +VITE_OIDC_ISSUER= +VITE_OIDC_CLIENT_ID= \ No newline at end of file diff --git a/.eslintrc.cjs b/.eslintrc.cjs index d6c9537..ee72acc 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -14,5 +14,6 @@ module.exports = { 'warn', { allowConstantExport: true }, ], + '@typescript-eslint/no-unused-vars': 'warn' }, } diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..a8a887d --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,82 @@ +name: ci +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + - uses: bahmutov/npm-install@v1 + - run: yarn build + #- run: yarn test + + check_if_version_upgraded: + name: Check if version upgrade + if: github.event_name == 'push' + runs-on: ubuntu-latest + needs: test + outputs: + from_version: ${{ steps.step1.outputs.from_version }} + to_version: ${{ steps.step1.outputs.to_version }} + is_upgraded_version: ${{ steps.step1.outputs.is_upgraded_version }} + steps: + - uses: garronej/ts-ci@v2.1.2 + id: step1 + with: + action_name: is_package_json_version_upgraded + branch: ${{ github.head_ref || github.ref }} + + create_github_release: + runs-on: ubuntu-latest + needs: check_if_version_upgraded + # We create a release only if the version have been upgraded and we are on a default branch + if: needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' && github.event_name == 'push' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + - uses: softprops/action-gh-release@v1 + with: + name: Release v${{ needs.check_if_version_upgraded.outputs.to_version }} + tag_name: v${{ needs.check_if_version_upgraded.outputs.to_version }} + target_commitish: ${{ github.head_ref || github.ref }} + generate_release_notes: true + draft: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + docker: + runs-on: ubuntu-latest + needs: + - check_if_version_upgraded + - create_github_release + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Computing Docker image tags + id: step1 + env: + IS_UPGRADED_VERSION: ${{ needs.check_if_version_upgraded.outputs.is_upgraded_version }} + TO_VERSION: ${{ needs.check_if_version_upgraded.outputs.to_version }} + run: | + OUT=$GITHUB_REPOSITORY:$TO_VERSION,$GITHUB_REPOSITORY:latest + OUT=$(echo "$OUT" | awk '{print tolower($0)}') + echo ::set-output name=docker_tags::$OUT + - uses: docker/build-push-action@v5 + with: + push: true + context: . + tags: ${{ steps.step1.outputs.docker_tags }} + platforms: linux/amd64,linux/arm64 \ No newline at end of file diff --git a/.gitignore b/.gitignore index a547bf3..61f4d30 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ dist-ssr *.njsproj *.sln *.sw? + +/public/dsfr/ diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..b27d048 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +/node_modules/ +/dist/ +/.eslintrc.js \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..2ec7e37 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,10 @@ +{ + "printWidth": 105, + "tabWidth": 4, + "useTabs": false, + "semi": true, + "singleQuote": false, + "trailingComma": "none", + "bracketSpacing": true, + "arrowParens": "avoid" +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..99b9e3f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ + +# build environment +FROM node:20-alpine as build +WORKDIR /app +COPY . . +RUN yarn install --frozen-lockfile +RUN yarn build + +# production environment +FROM nginxinc/nginx-unprivileged:1.25-alpine + +# Non root user +ENV NGINX_USER_ID=101 +ENV NGINX_GROUP_ID=101 +ENV NGINX_USER=nginx + +USER $NGINX_USER_ID + +COPY --from=build /app/nginx.conf /etc/nginx/conf.d/default.conf +WORKDIR /usr/share/nginx/html +COPY --from=build /app/dist . +ENTRYPOINT sh -c "./vite-envs.sh && nginx -g 'daemon off;'" \ No newline at end of file diff --git a/README.md b/README.md index 0d6babe..ccb57ba 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,6 @@ # React + TypeScript + Vite -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. - -Currently, two official plugins are available: - -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh - -## Expanding the ESLint configuration - -If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: - -- Configure the top-level `parserOptions` property like this: - -```js -export default { - // other rules... - parserOptions: { - ecmaVersion: 'latest', - sourceType: 'module', - project: ['./tsconfig.json', './tsconfig.node.json'], - tsconfigRootDir: __dirname, - }, -} +```env +DOCKERHUB_USERNAME=your_username +DOCKERHUB_TOKEN=your_token ``` - -- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` -- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` -- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list diff --git a/index.html b/index.html index e4b78ea..688627e 100644 --- a/index.html +++ b/index.html @@ -1,13 +1,24 @@ -
- - - -