diff --git a/.github/workflows/sharevb-docker-realease.yml b/.github/workflows/sharevb-docker-realease.yml index c622b8a7..6832ab37 100644 --- a/.github/workflows/sharevb-docker-realease.yml +++ b/.github/workflows/sharevb-docker-realease.yml @@ -62,6 +62,19 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build and push (BASE_URL) + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + build-args: | + "BASE_URL=/it-tools/" + platforms: linux/amd64,linux/arm64 + push: true + tags: | + sharevb/it-tools:baseurl-it-tools + ghcr.io/sharevb/it-tools:baseurl-it-tools + - name: Build and push uses: docker/build-push-action@v5 with: @@ -73,7 +86,6 @@ jobs: sharevb/it-tools:latest ghcr.io/${{ github.repository_owner }}/it-tools:latest - # Optionally log out - name: Log out from GitHub Container Registry run: docker logout ghcr.io \ No newline at end of file diff --git a/.github/workflows/sharevb-releases.yml b/.github/workflows/sharevb-releases.yml index 59a4016c..153463dc 100644 --- a/.github/workflows/sharevb-releases.yml +++ b/.github/workflows/sharevb-releases.yml @@ -34,6 +34,21 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build and push (BASE_URL) + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + build-args: | + "BASE_URL=/it-tools/" + platforms: linux/amd64,linux/arm64 + push: true + tags: | + sharevb/it-tools:baseurl-it-tools + sharevb/it-tools:${{ env.RELEASE_VERSION}}-baseurl-it-tools + ghcr.io/sharevb/it-tools:baseurl-it-tools + ghcr.io/sharevb/it-tools:${{ env.RELEASE_VERSION}}-baseurl-it-tools + - name: Build and push uses: docker/build-push-action@v5 with: diff --git a/README.md b/README.md index 2b2ba3af..290388c6 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,6 @@ You can use my image in your docker-compose file if you want an update to date v Almost [all tools PR of it-tools](https://github.com/sharevb/it-tools/pulls). -## Build docker image for a subfolder - -According to https://github.com/sharevb/it-tools/pull/461#issuecomment-1602506049: -``` -docker build -t it-tools --build-arg BASE_URL="/my-folder/" . -docker run -d --name it-tools --restart unless-stopped -p 8080:8080 it-tools -``` - ## Docker images [GitHub Container Registry](https://github.com/sharevb/it-tools/pkgs/container/it-tools): `ghcr.io/sharevb/it-tools:latest` @@ -41,6 +33,102 @@ services: - 8080:8080 ``` +## Build docker image for a custom subfolder + +According to https://github.com/sharevb/it-tools/pull/461#issuecomment-1602506049 and https://github.com/CorentinTh/it-tools/pull/461: +``` +docker build -t it-tools --build-arg BASE_URL="/my-folder/" . +docker run -d --name it-tools --restart unless-stopped -p 8080:8080 it-tools +``` + +Then if you go to `http://localhost:8080` you'll get a blank page, but opening the DevTools (& refreshing) you'll notice in the Network tab that the app is trying to fetch assets from `/my-folder/...` + +So you would need to put another server in front of it, like [Nginx Proxy Manager](https://nginxproxymanager.com/), [Traefik](https://traefik.io/traefik/), [caddy](https://caddyserver.com/) etc. Then setup a reverse proxy pass using `/my-folder` + +## Docker compose for hosting in a `/it-tools/` subfolder + +For `/it-tools/` subfolder, you can use `baseurl-it-tools` tag. + +See (sample of docker-compose.yml and nginx.conf)[https://github.com/sharevb/it-tools/docker-subfolder-sample], this docker image needs to have another reverse proxy in front of it, like [Nginx Proxy Manager](https://nginxproxymanager.com/), [Traefik](https://traefik.io/traefik/), [caddy](https://caddyserver.com/) etc. + +Setup a reverse proxy pass using `/it-tools/`. + + +## To build using a custom folder: + +1. `BASE_URL="/it-tools/" pnpm build` +2. Rename the generated `dist` folder to `it-tools` and serve on `https://your-domain.com/it-tools` + +## To build for GitHub Pages: + +1. Enable GitHub Pages build and deployment option in your fork, under **Settings** > **Pages** and select **GitHub Actions** as the source +2. Add the following GitHub action to your repo: + +.github/workflows/deploy-pages.yaml +```yaml +name: Deploy static content to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + - uses: pnpm/action-setup@v2 + name: Install pnpm + id: pnpm-install + with: + version: 8 + run_install: true + + - name: Build + run: | + BASE_URL="/it-tools/" pnpm build + cp dist/index.html dist/404.html + + - name: Setup Pages + uses: actions/configure-pages@v3 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: './dist' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 +``` + ## Installation methods Local installation required installing first: `python3 make g++` diff --git a/docker-subfolder-sample/docker-compose.yml b/docker-subfolder-sample/docker-compose.yml new file mode 100644 index 00000000..a1390aaf --- /dev/null +++ b/docker-subfolder-sample/docker-compose.yml @@ -0,0 +1,14 @@ +services: + it-tools: + container_name: it-tools-subfolder + image: ghcr.io/sharevb/it-tools:baseurl-it-tools + pull_policy: always + restart: unless-stopped + nginx-reverse-proxy: + image: nginx:alpine + depends_on: + - it-tools + volumes: + - "./nginx.conf:/etc/nginx/conf.d/nginx.conf" + ports: + - 8080:8080 \ No newline at end of file diff --git a/docker-subfolder-sample/nginx.conf b/docker-subfolder-sample/nginx.conf new file mode 100644 index 00000000..f5e5f49a --- /dev/null +++ b/docker-subfolder-sample/nginx.conf @@ -0,0 +1,8 @@ +server { + listen 8080; + server_name _; + + location /it-tools/ { + proxy_pass http://it-tools-subfolder:8080/; + } +} diff --git a/vite.config.ts b/vite.config.ts index ab8064e6..a66af72a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -69,22 +69,22 @@ export default defineConfig({ background_color: '#f1f5f9', icons: [ { - src: '/favicon-16x16.png', + src: `${baseUrl}favicon-16x16.png`, type: 'image/png', sizes: '16x16', }, { - src: '/favicon-32x32.png', + src: `${baseUrl}favicon-32x32.png`, type: 'image/png', sizes: '32x32', }, { - src: '/android-chrome-192x192.png', + src: `${baseUrl}android-chrome-192x192.png`, sizes: '192x192', type: 'image/png', }, { - src: '/android-chrome-512x512.png', + src: `${baseUrl}android-chrome-512x512.png`, sizes: '512x512', type: 'image/png', purpose: 'any maskable',