diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..581eced --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git/ +.parcel-cache/ +dist/ +node_modules/ +.gitignore +package-lock.json +readme.md \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 4358236..f97d443 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -7,16 +7,83 @@ on: jobs: - build: + load_code: + name: Load Code runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: Archive code + uses: actions/upload-artifact@v4.3.1 + with: + name: source-code + path: . + + build: + name: Build + needs: load_code + runs-on: ubuntu-latest + steps: + - name: Download code + uses: actions/download-artifact@v4.1.2 + with: + name: source-code + path: . + + - name: Setup Node 20 + uses: actions/setup-node@v4.0.2 with: node-version: 20 - name: Install Dependencies run: npm install - name: Build run: npm run build + + metadata: + name: Metadata + runs-on: ubuntu-latest + steps: + - id: meta + name: Extract metadata + uses: docker/metadata-action@v5.5.1 + with: + images: ghcr.io/${{ github.repository }} + outputs: + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + + containerize: + name: Containerize + needs: [load_code, metadata] + runs-on: ubuntu-latest + permissions: + id-token: write + packages: write + steps: + - name: Download code + uses: actions/download-artifact@v4.1.2 + with: + name: source-code + path: . + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.0.0 + + - name: Login to ghcr.io + uses: docker/login-action@v3.0.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push to ghcr.io + uses: docker/build-push-action@v5.1.0 + with: + context: . + file: ./Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + + tags: ${{ needs.metadata.outputs.tags }} + labels: ${{ needs.metadata.outputs.labels }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 12e5286..e3dfdea 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,49 +3,80 @@ name: Release on: release: types: [published] - -permissions: - contents: read - pages: write - id-token: write - -concurrency: - group: "pages" - cancel-in-progress: false - + jobs: - build: + load_code: + permissions: + contents: read + name: Load Code runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup Pages - uses: actions/configure-pages@v4 + - name: Archive code + uses: actions/upload-artifact@v4.3.1 + with: + name: source-code + path: . + + build: + name: Build + needs: load_code + runs-on: ubuntu-latest + steps: + - name: Download code + uses: actions/download-artifact@v4.1.2 + with: + name: source-code + path: . - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: Setup Node 20 + uses: actions/setup-node@v4.0.2 with: node-version: 20 - name: Install Dependencies run: npm install - - name: Build run: npm run build + - name: Upload builded code + uses: actions/upload-artifact@v4.3.1 + with: + name: dist + path: dist + + dist_to_page: + name: Dist to Page + needs: build + runs-on: ubuntu-latest + steps: + - name: Download builded code + uses: actions/download-artifact@v4.1.2 + with: + name: dist + path: dist + - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v3.0.1 with: - name: github-pages - path: dist/ + name: github-pages + path: dist/ deploy: + name: Deploy + permissions: + pages: write + id-token: write + concurrency: + group: "pages" + cancel-in-progress: false environment: name: github-pages url: https://stft.max.mielchen.io runs-on: ubuntu-latest - needs: build + needs: dist_to_page steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@v4.0.4 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..21f1c09 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM node:20.11.0 as builder + +WORKDIR /app + +COPY . . +RUN npm install + +RUN npm run-script build + +FROM nginx:1.25.3 + +COPY --from=builder /app/dist /usr/share/nginx/html diff --git a/package.json b/package.json index 7276175..1c677e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stft", - "version": "1.0.2", + "version": "1.0.3", "description": "Simtrade Farming Tool", "source": "src/index.html", "scripts": { @@ -18,5 +18,9 @@ "react": "^18.2.0", "react-bootstrap": "^2.10.0", "react-dom": "^18.2.0" + }, + "optionalDependencies": { + "@parcel/watcher-linux-x64-glibc": "^2.4.0", + "@parcel/watcher-linux-arm64-glibc": "^2.4.0" } }