-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
200 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
weight: 5 | ||
title: 'Enum field' | ||
--- | ||
|
||
# Enum field | ||
|
||
{{< br >}} | ||
|
||
In the table page, an enum field will look like this | ||
|
||
![field image](/adomin/images/models/enum/table_enum.png) | ||
|
||
In the create / edit page | ||
|
||
![edit field image](/adomin/images/models/enum/enum.png) | ||
|
||
## Config | ||
|
||
### options | ||
|
||
Options for the select component | ||
|
||
example: | ||
|
||
```ts | ||
{ | ||
type: 'enum', | ||
label: 'Test enum', | ||
options: [ | ||
{ label: '(Non renseigné)', value: null }, | ||
{ label: 'Salut', value: 'ref_1' }, | ||
{ label: 'Au revoir', value: 'ref_2' }, | ||
], | ||
} | ||
``` | ||
|
||
### defaultValue | ||
|
||
Optionnal, a static default value to show on the creation form |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
weight: 3 | ||
title: 'Deployment' | ||
|
||
--- | ||
|
||
# Frontend deployment | ||
|
||
{{< br >}} | ||
|
||
To deploy the Adomin frontend, you will need to: | ||
|
||
- run `yarn build` with correct VITE_API_URL env variable set | ||
- copy dist folder to your static files service | ||
- serve those files with a rule for SPAs (e.g. serving the index.html on 404) | ||
|
||
## S3 / Cloudfront | ||
|
||
```fish | ||
# copy dist files into your s3 bucket | ||
aws s3 sync ./dist s3://your-s3-bucket-name/ | ||
# invalidate cloudfront distribution to serve the new files | ||
aws cloudfront create-invalidation --distribution-id YOUR_DISTRIB_ID --paths "/*" | ||
``` | ||
|
||
### Github action for S3 / Cloudfront | ||
|
||
```yml | ||
name: Deploy staging ⚙️ | ||
on: | ||
push: | ||
branches: | ||
- does-not-exist # replace by e.g: staging | ||
|
||
jobs: | ||
back-office: | ||
runs-on: ubuntu-latest | ||
env: | ||
VITE_API_URL: https://api.staging.your-own-domain.fr/ # replace by your API url | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
run: yarn | ||
- name: Build | ||
run: yarn build | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
# you will have to create AWS_ACCESS_KEY and AWS_SECRET_KEY secrets in your repository settings | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | ||
aws-region: eu-west-3 | ||
- name: Deploy | ||
run: aws s3 sync ./dist s3://your-s3-bucket-name/ # replace by your s3 bucket name | ||
- name: Invalidate dashboard cloudfront | ||
run: aws cloudfront create-invalidation --distribution-id YOUR_DISTRIB_ID --paths "/*" # replace by your cloudfront distribution id | ||
``` | ||
## Caddy | ||
Example of Caddy config to serve a SPA | ||
``` | ||
example.com { | ||
root * /usr/share/caddy/frontend | ||
file_server | ||
try_files {path} {path}/ /index.html | ||
} | ||
``` | ||
|
||
### Github action for Caddy | ||
|
||
This github action is taken from a project that uses [Galacrypt](https://github.com/galadrimteam/galacrypt) to encrypt/decrypt the | ||
|
||
```yml | ||
name: Deploy staging ⚙️ | ||
on: | ||
push: | ||
branches: | ||
- does-not-exist # replace by e.g: staging | ||
|
||
jobs: | ||
frontend: | ||
runs-on: ubuntu-latest | ||
env: | ||
VITE_API_URL: https://api.staging.your-own-domain.fr/ # replace by your API url | ||
SERVER_IP: 1.2.3.4 # replace by your server IP | ||
KEY_PATH: ./ssh_keys/staging/id_ed25519 # do not commit/push this file directly | ||
SSH_USER: YOUR_SSH_USER # replace by your ssh user | ||
SSH_PARAMS: -i ./ssh_keys/staging/id_ed25519 [email protected] # replace dummy user / ip | ||
|
||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
cache: 'yarn' | ||
|
||
- name: Dependencies installation | ||
run: yarn | ||
|
||
- name: Galacrypt decrypt # used to decrypt ssh key, you will have to create GALACRYPT_KEY in your repository secrets | ||
run: yarn galacrypt use ${{ secrets.GALACRYPT_KEY }} && yarn galacrypt decrypt | ||
|
||
- name: Generate build | ||
run: yarn build | ||
|
||
- name: Generate frontend zip | ||
run: cd dist && zip -r ../frontend.zip . | ||
|
||
- name: Setup SSH | ||
run: | | ||
mkdir -p ~/.ssh | ||
ssh-keyscan $SERVER_IP 2>/dev/null > ~/.ssh/known_hosts | ||
chmod 600 $KEY_PATH | ||
- name: Copy files | ||
run: scp -i $KEY_PATH ./frontend.zip $SSH_USER@$SERVER_IP:/home/$SSH_USER/frontend.zip | ||
|
||
- name: Unzip | ||
run: ssh $SSH_PARAMS "cd /home/$SSH_USER/ && rm -rf front-build && mkdir front-build && mv frontend.zip front-build/ && cd front-build && unzip frontend.zip && rm frontend.zip" | ||
|
||
- name: Move website files | ||
run: ssh $SSH_PARAMS "cd /home/$SSH_USER/ && (sudo mv /usr/share/caddy/frontend old_frontend || echo 'skipping mv old_frontend') && sudo mv front-build /usr/share/caddy/frontend && sudo rm -rf old_frontend" | ||
``` | ||
## Nginx | ||
I don't want to deal with nginx anymore, but if you want to, you can find inspiration [here](https://sdickinson.com/nginx-config-for-single-page-applications/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.