[a] add metrics port export to Dockerfile
All checks were successful
Build and Push Docker Image / docker-build (push) Successful in 11s

This commit is contained in:
Sangelo 2024-10-21 16:13:39 +02:00
parent 9c0daaba4b
commit 7e175c597b
3 changed files with 12 additions and 3 deletions

View file

@ -1,10 +1,16 @@
# container img
FROM node:14 FROM node:14
WORKDIR /app WORKDIR /app
# copy files and install deps
COPY package*.json ./ COPY package*.json ./
RUN npm install RUN npm install
COPY . . COPY . .
# # main port
EXPOSE 3000 EXPOSE 3000
# metrics port
EXPOSE 3001
CMD ["node", "main.js"] CMD ["node", "main.js"]

View file

@ -14,12 +14,14 @@ RATE_LIMIT_MINUTES=15 # the amount of time in minutes to rate limit
RATE_LIMIT_REQUESTS=100 # amount of max. requests 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`. Don't change the `PORT` and `METRICS_PORT` values when running in a Docker Container.
Instead, export a different port and forward that to the container's ports `3000` and `3001` for the main API port and the metrics port respectively.
```yml ```yml
# example for docker-compose.yml: # example for docker-compose.yml:
ports: ports:
- "5678:3000" - "5678:3000"
- "6789:3001"
``` ```
You also have to mount the `.env` file inside the container, if you're using Docker: You also have to mount the `.env` file inside the container, if you're using Docker:

View file

@ -3,6 +3,7 @@ services:
image: gitpot.org/sangelo/plausible-pageviews-api:main image: gitpot.org/sangelo/plausible-pageviews-api:main
container_name: plausible-pageviews-api container_name: plausible-pageviews-api
ports: ports:
- "3000:3000" - "3000:3000" # main port
- "3001:3001" # metrics port
volumes: volumes:
- ./.env:/app/.env - ./.env:/app/.env