diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml new file mode 100644 index 0000000..f8f5e0c --- /dev/null +++ b/.forgejo/workflows/build.yml @@ -0,0 +1,47 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + tags: + - "v*" + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ gitea.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-22.04:docker://ghcr.io/catthehacker/ubuntu:act-22.04 + steps: + - name: ⬇️ Checkout repository + uses: actions/checkout@v3 + + - name: 👤 Log in to the Container registry + uses: github.com/docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ gitea.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: ✏️ Extract metadata (tags, labels) for Docker + id: meta + uses: github.com/docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: 🛠️ Build and push Docker image + uses: github.com/docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1dadeb5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:14 +WORKDIR /app + +COPY package*.json ./ +RUN npm install +COPY . . + +# +EXPOSE 3000 +CMD ["node", "main.js"] diff --git a/README.md b/README.md index 48eda4c..17b36a5 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,21 @@ RATE_LIMIT_MINUTES=15 # the amount of time in minutes to rate limit RATE_LIMIT_REQUESTS=100 # amount of max. requests ``` +Don't change the `PORT` value when running in a Docker Container. Instead, export a different port and forward that to the container's port `3000`. + +```yml +# example for docker-compose.yml: +ports: + - "5678:3000" +``` + +You also have to mount the `.env` file inside the container, if you're using Docker: + +```yml +volumes: + - .env:/app/.env +``` + ## Run the API ```bash