Kantuta POS Backend ships with a ready-to-useDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Eleazarguitar18/kantuta_pos_back/llms.txt
Use this file to discover all available pages before exploring further.
Dockerfile and docker-compose.yml so you can spin up the NestJS API in an isolated container with a single command. This guide walks you through local and production deployment, explains every relevant configuration option in the compose file, and covers useful day-to-day operational tasks such as tailing logs and building standalone images.
Prerequisites
- Docker Engine v24+ installed and running
- Docker Compose v2.x (
docker composeCLI plugin, not the legacydocker-compose) - A running PostgreSQL instance and a running Redis instance accessible from within the container (see the host.docker.internal note below)
Using docker-compose
Clone the repository and create your .env file
Clone the project and copy your environment configuration into At minimum you must populate the database and Redis variables before starting the container. Refer to the Environment Variables page for the full list.
.env. Docker Compose will automatically inject every variable in this file into the container.Build and start the container
Run the following command from the project root. Docker Compose builds the image from the local The first build downloads the
Dockerfile and starts the nest_api_kantuta service on port 3000.node:20-alpine base image and installs all npm dependencies; subsequent builds reuse the cached layer unless package.json changes.docker-compose.yml explained
Below is the fulldocker-compose.yml with an explanation of each key section:
| Key | Value | Purpose |
|---|---|---|
container_name | nest_api_kantuta | Fixed name for the container — used when running docker logs, docker exec, etc. |
ports | 3000:3000 | Maps host port 3000 to container port 3000. Change the first number if port 3000 is already in use on your host. |
volumes (source mount) | .:/usr/src/app | Mounts the project root into the container so file changes on the host are immediately reflected — ideal for development with start:dev. |
volumes (node_modules) | /usr/src/app/node_modules | Anonymous volume that shadows the host’s node_modules directory. Prevents conflicts between packages compiled for your host OS and packages compiled inside the Alpine container. |
env_file | .env | Loads every KEY=VALUE pair from the .env file as environment variables available inside the container. The .env file is never baked into the image. |
extra_hosts | host.docker.internal:host-gateway | Injects a /etc/hosts entry that resolves the special hostname host.docker.internal to the Docker host’s gateway IP. This lets the container reach services (PostgreSQL, Redis) running directly on your host machine. |
restart | always | Instructs Docker to automatically restart the container if it exits or if the Docker daemon restarts — suitable for both development servers and production. |
Note on host.docker.internal and Linux
On macOS and Windows Docker Desktop resolves host.docker.internal automatically. On Linux this hostname is not added by default, which is exactly why the extra_hosts: host.docker.internal:host-gateway line exists. Without it, any connection string pointing to host.docker.internal will fail to resolve on a Linux host.
If your PostgreSQL or Redis instance runs inside another Docker container (rather than on the host), add it as a service in this
docker-compose.yml and use the service name as the hostname instead of host.docker.internal.Building the image independently
If you only need to build the Docker image without starting a container — for example to push it to a registry — usedocker build directly:
Running in production (detached mode)
For production or any long-lived deployment, start the container in detached mode so it runs in the background and survives terminal closure:Accessing container logs
Stream live logs from the running container:Dockerfile reference
The projectDockerfile is based on the official node:20-alpine image and installs git and nano as development utilities. Dependencies are cached as a separate layer before the source code is copied, keeping rebuilds fast when only application code changes.
The default
CMD runs start:dev (Webpack watch mode). For a production image you should override this command — either via the command: key in docker-compose.yml or by building a separate production Dockerfile — to run npm run start:prod after compiling the project with npm run build.