Skip to content

Commit

Permalink
chore(landing): update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaslz committed Mar 9, 2024
1 parent c792a01 commit 011c21c
Show file tree
Hide file tree
Showing 79 changed files with 1,628 additions and 398 deletions.
297 changes: 134 additions & 163 deletions .github/workflows/fito-deploy-production-live-main-on-push.yml
Original file line number Diff line number Diff line change
@@ -1,164 +1,135 @@
---
name: "production-live"
on:
workflow_dispatch: {}
push:
branches:
- "main"
paths-ignore:
- ".github/workflows/fito-deploy-*.yml"
- "**/*.md"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: false
env:
SSH_USER: "${{ secrets.FITO_ENV_CONNECTION_USER }}"
SSH_KEY: "${{ secrets.FITO_ENV_CONNECTION_PRIVATE_KEY }}"
SSH_HOST: "${{ secrets.FITO_ENV_CONNECTION_HOST }}"
ATTEMPTS: "${{ github.run_number }}"
jobs:
install-dependencies:
name: "install dependencies"
runs-on: "ubuntu-latest"
steps:
-
name: "Checkout under $GITHUB_WORKSPACE"
uses: "actions/checkout@v4"
with:
ref: "main"
-
name: "Set up NodeJS"
uses: "actions/setup-node@v3"
with:
node-version: "18.17"
-
name: "Install yarn"
run: "npm install -g yarn"
-
name: "Install dependencies"
run: "yarn install"
-
name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*"
key: "${{ github.sha }}-cache"
test:
name: "test"
runs-on: "ubuntu-latest"
needs: "install-dependencies"
steps:
-
name: "Set up NodeJS"
uses: "actions/setup-node@v3"
with:
node-version: "18.17"
-
name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*"
key: "${{ github.sha }}-cache"
-
name: "Run tests"
run: "yarn test"
build-application:
name: "build application"
runs-on: "ubuntu-latest"
needs: "test"
steps:
-
name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*"
key: "${{ github.sha }}-cache"
-
name: "Set up NodeJS"
uses: "actions/setup-node@v3"
with:
node-version: "18.17"
-
name: "Build application"
run: "yarn build"
-
name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*\nbuild\nnode_modules\npackage.json\nstatic"
key: "${{ github.sha }}-cache"
create-and-push-docker-image:
name: "create and push docker image"
runs-on: "ubuntu-latest"
needs: "build-application"
steps:
-
name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*\nbuild\nnode_modules\npackage.json\nstatic"
key: "${{ github.sha }}-cache"
-
name: "Build docker image"
run: "wget https://statics.dimaslz.dev/fito/docker/dockerfile-standard.docker.tmpl -O Dockerfile.tmpl\n export FROM=\"node:18.17-alpine\"\n export ARGS=\"\"\n export SOURCE=\"build\"\n export FILES=\"COPY node_modules /app/node_modules\nCOPY package.json /app/package.json\nCOPY static /app/static\"\n export PORT=\"3000\"\n export RUN_COMMAND=\"\\\"yarn\\\", \\\"start\\\"\"\n envsubst < Dockerfile.tmpl > Dockerfile\n docker build . -t ${{ env.ATTEMPTS }}_${{ github.sha }}_svelteuse.dimaslz.dev_production_image"
-
name: "prepare connection"
run: "mkdir -p ~/.ssh/\necho \"$SSH_KEY\" > ~/.ssh/prod.key\nchmod 600 ~/.ssh/prod.key\ncat >>~/.ssh/config <<END\nHost prod\n HostName $SSH_HOST\n User $SSH_USER\n IdentityFile ~/.ssh/prod.key\n StrictHostKeyChecking no\nEND"
-
name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*\nbuild\nnode_modules\npackage.json\nstatic"
key: "${{ github.sha }}-cache"
-
name: "Push image"
run: "docker save ${{ env.ATTEMPTS }}_${{ github.sha }}_svelteuse.dimaslz.dev_production_image | bzip2 | ssh prod 'docker load'"
deployment:
name: "run image and clean"
runs-on: "ubuntu-latest"
needs: "create-and-push-docker-image"
environment:
name: "production"
url: "https://svelteuse.dimaslz.dev"
steps:
-
name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*\nbuild\nnode_modules\npackage.json\nstatic"
key: "${{ github.sha }}-cache"
-
name: "prepare connection"
run: "mkdir -p ~/.ssh/\necho \"$SSH_KEY\" > ~/.ssh/prod.key\nchmod 600 ~/.ssh/prod.key\ncat >>~/.ssh/config <<END\nHost prod\n HostName $SSH_HOST\n User $SSH_USER\n IdentityFile ~/.ssh/prod.key\n StrictHostKeyChecking no\nEND"
-
name: "get current currentContainerId"
run: "currentContainerId=`ssh prod \"docker ps --format=\\\"{{.Names}} {{.ID}}\\\" | grep \\\"_svelteuse.dimaslz.dev\\\" || echo \\\"\\\"\"` && currentContainerId=`echo $currentContainerId | grep -Po \"\\s.*?$\" | tr -d \"\\n\" || echo \"\"` && echo \"currentContainerId=$currentContainerId\" >> $GITHUB_ENV"
-
name: "get current currentImageId"
run: "currentImageId=`ssh prod \"docker images --format=\\\"{{.Repository}} {{.ID}}\\\" | grep \\\"_svelteuse.dimaslz.dev\\\" || echo \\\"\\\"\"` && currentImageId=`echo $currentImageId | grep -Po \"\\s(.*?$)\" | tr -d \"\\n\" || echo \"\"` && echo \"currentImageId=$currentImageId\" >> $GITHUB_ENV"
-
name: "run"
run: "newContainerID=`ssh prod \"docker run --name ${{ env.ATTEMPTS }}_${{ github.sha }}_svelteuse.dimaslz.dev_production_container -d ${{ env.ATTEMPTS }}_${{ github.sha }}_svelteuse.dimaslz.dev_production_image \"` && echo \"newContainerID=$newContainerID\" >> $GITHUB_ENV"
-
name: "get container IP"
run: "newContainerIP=`ssh prod \"docker inspect -f \\\"{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}\\\" ${{ env.newContainerID }}\"` && echo \"newContainerIP=$newContainerIP\" >> $GITHUB_ENV"
-
name: "get container PORT"
run: "newContainerPort=`ssh prod \"docker container ls | grep \\\"${{ env.ATTEMPTS }}_${{ github.sha }}_svelteuse.dimaslz.dev_production\\\" | grep -Po \\\"\\d+/tcp \\\" | grep -Po \\\"\\d+\\\"\"` && echo \"newContainerPort=$newContainerPort\" >> $GITHUB_ENV"
-
name: "Container is not running"
if: "${{ failure() }}"
run: "echo \"container is not running\" && exit 1"
-
name: "setup nginx config"
run: "wget https://statics.dimaslz.dev/fito/nginx/static-config-auth.nginx-certbot-1-step.tmpl -O nginx.tmpl\n\texport SERVER_NAME=\"svelteuse.dimaslz.dev\"\n\texport SERVER_URL=\"http://${{ env.newContainerIP }}:${{ env.newContainerPort }}\"\n\tenvsubst < nginx.tmpl > svelteuse.dimaslz.dev\n\tscp svelteuse.dimaslz.dev prod:/etc/nginx/sites-enabled/svelteuse.dimaslz.dev\n\tssh prod \"nginx -t && systemctl restart nginx\""
-
name: "setup nginx config"
run: "wget https://statics.dimaslz.dev/fito/nginx/static-config-auth.nginx-certbot-2-step.tmpl -O nginx.tmpl\n\texport SERVER_NAME=\"svelteuse.dimaslz.dev\"\n\texport SERVER_URL=\"http://${{ env.newContainerIP }}:${{ env.newContainerPort }}\"\n\tenvsubst < nginx.tmpl > svelteuse.dimaslz.dev\n\tscp svelteuse.dimaslz.dev prod:/etc/nginx/sites-enabled/svelteuse.dimaslz.dev\n\tssh prod \"nginx -t && systemctl restart nginx\""
-
name: "setup .htpasswd authentication"
run: "ssh prod \"sh -c \\\"echo -n 'svelteuse:' > /etc/nginx/.svelteuse.dimaslz.dev-htpasswd\\\" & sh -c \\\"openssl passwd -apr1 ${{ secrets.FITO_ENV_SVELTEUSE_DIMASLZ_DEV }} >> /etc/nginx/.svelteuse.dimaslz.dev-htpasswd\\\"\""
-
name: "Container is not running"
if: "${{ failure() }}"
run: "echo \"container is not running\" && ssh prod \"docker rm -f ${{ env.newContainerID }}\" && exit 1"
name: "production-live"
on:
workflow_dispatch: {}
push:
branches:
- "main"
paths-ignore:
- ".github/workflows/fito-deploy-*.yml"
- "**/*.md"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: false
env:
SSH_USER: "${{ secrets.FITO_ENV_CONNECTION_USER }}"
SSH_KEY: "${{ secrets.FITO_ENV_CONNECTION_PRIVATE_KEY }}"
SSH_HOST: "${{ secrets.FITO_ENV_CONNECTION_HOST }}"
ATTEMPTS: "${{ github.run_number }}"
jobs:
install-dependencies:
name: "install dependencies"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout under $GITHUB_WORKSPACE"
uses: "actions/checkout@v4"
with:
ref: "main"
- name: "Set up NodeJS"
uses: "actions/setup-node@v3"
with:
node-version: "18.17"
- name: "Install yarn"
run: "npm install -g yarn"
- name: "Install dependencies"
run: "yarn install"
- name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*"
key: "${{ github.sha }}-cache"
test:
name: "test"
runs-on: "ubuntu-latest"
needs: "install-dependencies"
steps:
- name: "Set up NodeJS"
uses: "actions/setup-node@v3"
with:
node-version: "18.17"
- name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*"
key: "${{ github.sha }}-cache"
- name: "Run tests"
run: "yarn test"
build-application:
name: "build application"
runs-on: "ubuntu-latest"
needs: "test"
steps:
- name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*"
key: "${{ github.sha }}-cache"
- name: "Set up NodeJS"
uses: "actions/setup-node@v3"
with:
node-version: "18.17"
- name: "Build application"
run: "yarn build"
- name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*\nbuild\nnode_modules\npackage.json\nstatic"
key: "${{ github.sha }}-cache"
create-and-push-docker-image:
name: "create and push docker image"
runs-on: "ubuntu-latest"
needs: "build-application"
steps:
- name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*\nbuild\nnode_modules\npackage.json\nstatic"
key: "${{ github.sha }}-cache"
- name: "Build docker image"
run: "wget https://statics.dimaslz.dev/fito/docker/dockerfile-standard.docker.tmpl -O Dockerfile.tmpl\n export FROM=\"node:18.17-alpine\"\n export ARGS=\"\"\n export SOURCE=\"build\"\n export FILES=\"COPY node_modules /app/node_modules\nCOPY package.json /app/package.json\nCOPY static /app/static\"\n export PORT=\"3000\"\n export RUN_COMMAND=\"\\\"yarn\\\", \\\"start\\\"\"\n envsubst < Dockerfile.tmpl > Dockerfile\n docker build . -t ${{ env.ATTEMPTS }}_${{ github.sha }}_svelteuse.dimaslz.dev_production_image"
- name: "prepare connection"
run: "mkdir -p ~/.ssh/\necho \"$SSH_KEY\" > ~/.ssh/prod.key\nchmod 600 ~/.ssh/prod.key\ncat >>~/.ssh/config <<END\nHost prod\n HostName $SSH_HOST\n User $SSH_USER\n IdentityFile ~/.ssh/prod.key\n StrictHostKeyChecking no\nEND"
- name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*\nbuild\nnode_modules\npackage.json\nstatic"
key: "${{ github.sha }}-cache"
- name: "Push image"
run: "docker save ${{ env.ATTEMPTS }}_${{ github.sha }}_svelteuse.dimaslz.dev_production_image | bzip2 | ssh prod 'docker load'"
deployment:
name: "run image and clean"
runs-on: "ubuntu-latest"
needs: "create-and-push-docker-image"
environment:
name: "production"
url: "https://svelteuse.dimaslz.dev"
steps:
- name: "Cache"
uses: "actions/cache@v3"
with:
path: "./*\nbuild\nnode_modules\npackage.json\nstatic"
key: "${{ github.sha }}-cache"
- name: "prepare connection"
run: "mkdir -p ~/.ssh/\necho \"$SSH_KEY\" > ~/.ssh/prod.key\nchmod 600 ~/.ssh/prod.key\ncat >>~/.ssh/config <<END\nHost prod\n HostName $SSH_HOST\n User $SSH_USER\n IdentityFile ~/.ssh/prod.key\n StrictHostKeyChecking no\nEND"
- name: "get current currentContainerId"
run: "currentContainerId=`ssh prod \"docker ps --format=\\\"{{.Names}} {{.ID}}\\\" | grep \\\"_svelteuse.dimaslz.dev\\\" || echo \\\"\\\"\"` && currentContainerId=`echo $currentContainerId | grep -Po \"\\s.*?$\" | tr -d \"\\n\" || echo \"\"` && echo \"currentContainerId=$currentContainerId\" >> $GITHUB_ENV"
- name: "get current currentImageId"
run: "currentImageId=`ssh prod \"docker images --format=\\\"{{.Repository}} {{.ID}}\\\" | grep \\\"_svelteuse.dimaslz.dev\\\" || echo \\\"\\\"\"` && currentImageId=`echo $currentImageId | grep -Po \"\\s(.*?$)\" | tr -d \"\\n\" || echo \"\"` && echo \"currentImageId=$currentImageId\" >> $GITHUB_ENV"
- name: "run"
run: 'newContainerID=`ssh prod "docker run --name ${{ env.ATTEMPTS }}_${{ github.sha }}_svelteuse.dimaslz.dev_production_container -d ${{ env.ATTEMPTS }}_${{ github.sha }}_svelteuse.dimaslz.dev_production_image "` && echo "newContainerID=$newContainerID" >> $GITHUB_ENV'
- name: "get container IP"
run: "newContainerIP=`ssh prod \"docker inspect -f \\\"{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}\\\" ${{ env.newContainerID }}\"` && echo \"newContainerIP=$newContainerIP\" >> $GITHUB_ENV"
- name: "get container PORT"
run: "newContainerPort=`ssh prod \"docker container ls | grep \\\"${{ env.ATTEMPTS }}_${{ github.sha }}_svelteuse.dimaslz.dev_production\\\" | grep -Po \\\"\\d+/tcp \\\" | grep -Po \\\"\\d+\\\"\"` && echo \"newContainerPort=$newContainerPort\" >> $GITHUB_ENV"
- name: "Container is not running"
if: "${{ failure() }}"
run: 'echo "container is not running" && exit 1'
- name: "setup nginx config"
run: "wget https://statics.dimaslz.dev/fito/nginx/static-config-auth.nginx-certbot-1-step.tmpl -O nginx.tmpl\n\texport SERVER_NAME=\"svelteuse.dimaslz.dev\"\n\texport SERVER_URL=\"http://${{ env.newContainerIP }}:${{ env.newContainerPort }}\"\n\tenvsubst < nginx.tmpl > svelteuse.dimaslz.dev\n\tscp svelteuse.dimaslz.dev prod:/etc/nginx/sites-enabled/svelteuse.dimaslz.dev\n\tssh prod \"nginx -t && systemctl restart nginx\""
- name: "setup nginx config"
run: "wget https://statics.dimaslz.dev/fito/nginx/static-config-auth.nginx-certbot-2-step.tmpl -O nginx.tmpl\n\texport SERVER_NAME=\"svelteuse.dimaslz.dev\"\n\texport SERVER_URL=\"http://${{ env.newContainerIP }}:${{ env.newContainerPort }}\"\n\tenvsubst < nginx.tmpl > svelteuse.dimaslz.dev\n\tscp svelteuse.dimaslz.dev prod:/etc/nginx/sites-enabled/svelteuse.dimaslz.dev\n\tssh prod \"nginx -t && systemctl restart nginx\""
- name: "setup .htpasswd authentication"
run: "ssh prod \"sh -c \\\"echo -n 'svelteuse:' > /etc/nginx/.svelteuse.dimaslz.dev-htpasswd\\\" & sh -c \\\"openssl passwd -apr1 ${{ secrets.FITO_ENV_SVELTEUSE_DIMASLZ_DEV }} >> /etc/nginx/.svelteuse.dimaslz.dev-htpasswd\\\"\""
- name: "Container is not running"
if: "${{ failure() }}"
run: 'echo "container is not running" && ssh prod "docker rm -f ${{ env.newContainerID }}" && exit 1'
32 changes: 16 additions & 16 deletions .packito.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"remove": {
"devDependencies": "*",
"scripts": "*",
"type": true,
"esm": true,
"husky": true,
"commitlint": true
},
"replace": {
"main": "index.js",
"module": "index.mjs"
},
"copy": ["README.md", "LICENSE"],
"publisher": "npm",
"output": "./publish"
}
"remove": {
"devDependencies": "*",
"scripts": "*",
"type": true,
"esm": true,
"husky": true,
"commitlint": true
},
"replace": {
"main": "index.js",
"module": "index.mjs"
},
"copy": ["README.md", "LICENSE"],
"publisher": "npm",
"output": "./publish"
}
5 changes: 2 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
"singleQuote": false,
"trailingComma": "all",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."]
}
"plugins": ["prettier-plugin-svelte"]
}
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ This list is orientative, let's try to get all 👨‍💻.
- [x] [useWindowSize](/src/hooks/useWindowSize): <https://usehooks.com/usewindowsize>, <https://usehooks-ts.com/react-hook/use-window-size>, <https://vueuse.org/core/useWindowSize/>

<!-- -->

- [ ] useLocation (https://vueuse.org/core/useBrowserLocation/)
- [ ] useEventCallback: <https://usehooks-ts.com/react-hook/use-event-callback>
- [ ] usePreferredDark (https://vueuse.org/core/usePreferredDark/)
Expand Down Expand Up @@ -155,23 +156,23 @@ This list is orientative, let's try to get all 👨‍💻.

```json
{
"name": "Dimas López Zurita",
"role": "Senior Software Engineer",
"alias": "dimaslz",
"linkedin": "https://www.linkedin.com/in/dimaslopezzurita",
"github": "https://github.com/dimaslz",
"twitter": "https://twitter.com/dimaslz",
"tags": "tooling, docker, tailwindcss, vue, SAAS, nodejs+express"
"name": "Dimas López Zurita",
"role": "Senior Software Engineer",
"alias": "dimaslz",
"linkedin": "https://www.linkedin.com/in/dimaslopezzurita",
"github": "https://github.com/dimaslz",
"twitter": "https://twitter.com/dimaslz",
"tags": "tooling, docker, tailwindcss, vue, SAAS, nodejs+express"
}
```

## My other projects

* [https://ng-heroicons.dimaslz.dev/](https://ng-heroicons.dimaslz.dev/): An Angular components library to use Heroicons.com in your Angular projects.
* [https://randomdata.loremapi.io/](https://randomdata.loremapi.io/): A tool to create mock Api responses with your custom schema.
* [https://svg-icon-2-fw-component.dimaslz.dev](https://svg-icon-2-fw-component.dimaslz.dev): A tool to create a framework icon component from a SVG
* [https://loremapi.io](https://loremapi.io): Mock and document your Api's
* [https://cv.dimaslz.dev](https://cv.dimaslz.dev): My online CV
* [https://api.dimaslz.dev](https://api.dimaslz.dev): My professional info by API
* [https://dimaslz.dev](https://dimaslz.dev): Dev landing
* [https://dimaslz.com](https://dimaslz.com): Profesional landing profile
- [https://ng-heroicons.dimaslz.dev/](https://ng-heroicons.dimaslz.dev/): An Angular components library to use Heroicons.com in your Angular projects.
- [https://randomdata.loremapi.io/](https://randomdata.loremapi.io/): A tool to create mock Api responses with your custom schema.
- [https://svg-icon-2-fw-component.dimaslz.dev](https://svg-icon-2-fw-component.dimaslz.dev): A tool to create a framework icon component from a SVG
- [https://loremapi.io](https://loremapi.io): Mock and document your Api's
- [https://cv.dimaslz.dev](https://cv.dimaslz.dev): My online CV
- [https://api.dimaslz.dev](https://api.dimaslz.dev): My professional info by API
- [https://dimaslz.dev](https://dimaslz.dev): Dev landing
- [https://dimaslz.com](https://dimaslz.com): Profesional landing profile
Loading

0 comments on commit 011c21c

Please sign in to comment.