Reduce Docker build memory use on small VPS
Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 7m39s
Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 7m39s
This commit is contained in:
@@ -43,6 +43,54 @@ Also set the following in Dokploy's regular runtime environment:
|
||||
Add any optional production variables from `.env.example` in Dokploy's
|
||||
environment settings. Do not upload `.env.local` or add it to the repository.
|
||||
|
||||
## Building on a 2 GiB VPS
|
||||
|
||||
The Dockerfile uses `npm run build:docker`. It generates route types and runs
|
||||
the full TypeScript check in a separate process before compiling with Webpack.
|
||||
Next.js skips its duplicate TypeScript check only after the separate check
|
||||
succeeds. The Docker build enables Webpack's build worker and memory
|
||||
optimizations, and keeps page collection at one worker. Each build Node process
|
||||
has a 640 MiB JavaScript heap ceiling; this is not a limit on the total memory
|
||||
used by all processes or native libraries.
|
||||
|
||||
Dependencies are installed once, then pruned after compilation. The dependency
|
||||
installation for the final image no longer runs independently alongside the
|
||||
application build. Normal `npm run build` retains its usual type checking and
|
||||
bundler behavior. See Next.js's [memory usage
|
||||
guide](https://nextjs.org/docs/app/guides/memory-usage) for the build options.
|
||||
|
||||
In Dokploy, keep builds concurrency at **1** on this VPS. Dokploy, PostgreSQL,
|
||||
Redis, Traefik, the running application, and the new build share the host's RAM.
|
||||
Avoid starting a panorama render during a deployment. Application runtime
|
||||
resource limits do not necessarily limit the Docker image build.
|
||||
|
||||
If the host freezes, capture these read-only diagnostics from the VPS shell
|
||||
before retrying. They print resource figures and Dokploy container state without
|
||||
environment values, API keys, private addresses, or repository names:
|
||||
|
||||
```sh
|
||||
free -m
|
||||
df -h /
|
||||
vmstat 1 5
|
||||
journalctl -k --since '30 minutes ago' --no-pager -o cat |
|
||||
awk '/oom-kill|Out of memory|Killed process/ {n++} END {print "Kernel OOM messages:", n+0}'
|
||||
docker ps -aq --filter label=com.docker.swarm.service.name=dokploy |
|
||||
xargs -r docker inspect --format 'OOMKilled={{.State.OOMKilled}} ExitCode={{.State.ExitCode}} Started={{.State.StartedAt}} Finished={{.State.FinishedAt}}'
|
||||
```
|
||||
|
||||
A startup log containing `Cancelled 1 deployments` is Dokploy's startup cleanup,
|
||||
not proof of a deployment timeout. Correlate container start/finish times and
|
||||
kernel OOM messages with the failed build. `OOMKilled=false` for Dokploy does not
|
||||
rule out a different process being killed or host-wide memory pressure. Journal
|
||||
permissions or missing history can also prevent the OOM count from being useful.
|
||||
|
||||
If swap is absent and memory pressure is confirmed, adding swap can prevent
|
||||
abrupt memory exhaustion, but it consumes disk space and can make builds slower.
|
||||
Approve server configuration changes separately; the repository changes do not
|
||||
create swap, restart services, or change server resource limits. If builds still
|
||||
exceed available memory, move image compilation to the MacBook runner and use a
|
||||
private image-transfer or private-registry workflow.
|
||||
|
||||
## Gitea Actions secrets
|
||||
|
||||
Add the following repository Actions secrets in Gitea. Use the HTTPS origin of
|
||||
|
||||
Reference in New Issue
Block a user