diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..153fb97 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.devcontainer +.git +.github +.vscode +.gitignore +Dockerfile +README.md +node_modules +package-lock.json +pnpm-lock.yaml +eslint.config.mjs +LICENSE \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..1a481eb --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for more information: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot + +version: 2 +updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: monthly diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..9324d55 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,32 @@ +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' +categories: + - title: 'πŸš€ Features' + labels: + - 'enhancement' + - 'feature' + - title: 'πŸ› Bug Fixes' + labels: + - 'bugfix' + - title: '🧰 Maintenance' + label: 'CI' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: patch +template: | + ## What's New + $CHANGES + + ## Contributors + + Thank you to our contributors for making this release possible: + $CONTRIBUTORS \ No newline at end of file diff --git a/.github/workflows/linter-builder-checker.yml b/.github/workflows/linter-builder-checker.yml new file mode 100644 index 0000000..d49dd94 --- /dev/null +++ b/.github/workflows/linter-builder-checker.yml @@ -0,0 +1,56 @@ +name: 'Linter and Builder checker πŸš€' +on: + pull_request: + branches: + - 'main' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + code_quality: + name: 'Code QualityπŸ“¦' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: npm install + - name: Run ESLint + run: npm run lint + + builder: + name: 'Build Docker ImageπŸ”¨' + runs-on: ubuntu-latest + needs: [code_quality] + strategy: + matrix: + config: + - { dockerfile: "Dockerfile", platforms: "linux/amd64,linux/arm64" } + + steps: + + - name: Check repo + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Get Commit Hash + id: commit + shell: bash + run: | + echo "SHORT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV + + - name: Build Docker image + if: startsWith(github.ref, 'refs/tags/') != true && success() + uses: docker/build-push-action@v4 + with: + context: . + push: false + platforms: ${{ matrix.config.platforms }} + tags: "ghcr.io/${{ secrets.NAMESPACE }}/${{ secrets.IMAGE_NAME }}:${{ env.SHORT_HASH }}" + file: ${{ matrix.config.dockerfile }} diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..01dcb72 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,38 @@ +name: 'Release Drafter πŸš€' + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - main + # pull_request event is required only for autolabeler + pull_request: + # Only following types are handled by the action, but one can default to all as well + types: [opened, reopened, synchronize] + # pull_request_target event is required for autolabeler to support PRs from forks + # pull_request_target: + # types: [opened, reopened, synchronize] + +permissions: + contents: read + +jobs: + update_release_draft: + permissions: + # write permission is required to create a github release + contents: write + # write permission is required for autolabeler + # otherwise, read permission is required at least + pull-requests: write + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "main" + - uses: release-drafter/release-drafter@v6 + # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml + with: + config-name: release-drafter.yml + # https://github.com/release-drafter/release-drafter/issues/1125 + commitish: main + # disable-autolabeler: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release-image.yml b/.github/workflows/release-image.yml new file mode 100644 index 0000000..c610409 --- /dev/null +++ b/.github/workflows/release-image.yml @@ -0,0 +1,51 @@ +name: 'Releasing Image πŸš€' +on: + push: + tags: + - 'v*' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + release_image: + name: 'Releasing Image 🐳' + strategy: + matrix: + config: + - { dockerfile: "Dockerfile", platforms: "linux/amd64,linux/arm64" } + runs-on: ubuntu-latest + steps: + - name: Check repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Github Container Registry + uses: docker/login-action@v3 + if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') && success() + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get Tag Name + id: tag + shell: bash + run: | + echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + + - name: Push Docker image + if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') && success() + uses: docker/build-push-action@v4 + with: + context: . + push: true + platforms: ${{ matrix.config.platforms }} + tags: "ghcr.io/${{ secrets.NAMESPACE }}/${{ secrets.IMAGE_NAME }}:${{ env.TAG }}" + file: ${{ matrix.config.dockerfile }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bfeb2ab --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM node:20.15.1-slim +WORKDIR /app +COPY . . + +HEALTHCHECK --interval=300s --timeout=30s --start-period=5s --retries=3 CMD [ "node", "healthy-check.js" ] +RUN npm install -g pnpm && pnpm install +EXPOSE 8000 +ENTRYPOINT [ "npm", "start" ] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1031d8d --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +PROJECT_NAME:=voyager +CONTAINER_NAME:=voyager:v0.1.0 +PORT:=8000 + + +.PHONY: build +build: + @docker build -t $(CONTAINER_NAME) . + +.PHONY: run +run: build + @docker run --rm -p $(PORT):$(PORT) --name $(PROJECT_NAME) $(CONTAINER_NAME) \ No newline at end of file