Make the container deployable on Dokploy
domains.json was written next to server.js, i.e. into the image filesystem, so every redeploy discarded the domain -> glossary_id mappings. Its path is now overridable via DOMAINS_FILE and the image defaults it to /app/data, a subdirectory so that mounting a volume there does not shadow server.js and index.html in /app. Also adds a GET /health endpoint plus a Docker HEALTHCHECK that uses it. The probe deliberately does not call DeepL, so an upstream DeepL outage does not get the container restarted. .gitignore is new; .env holds a real API key and was previously untracked only by convention. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
17
Dockerfile
17
Dockerfile
@@ -7,10 +7,21 @@ FROM node:18-alpine
|
||||
WORKDIR /app
|
||||
COPY server.js index.html package.json ./
|
||||
|
||||
# DEEPL_API_KEY is passed at "docker run" time (via -e or --env-file), not
|
||||
# baked into the image. domains.json should be bind-mounted so glossary
|
||||
# data survives container restarts/recreation (see README).
|
||||
# DEEPL_API_KEY is passed at runtime (docker run -e / --env-file, or the
|
||||
# Dokploy "Environment" tab), never baked into the image.
|
||||
#
|
||||
# domains.json holds which DeepL glossary_id belongs to which domain and
|
||||
# direction. It must live on a mounted volume, otherwise every redeploy
|
||||
# builds a fresh filesystem and the mappings are lost. /app/data is a
|
||||
# subdirectory so mounting it does not shadow the app files in /app.
|
||||
ENV PORT=3000
|
||||
ENV DOMAINS_FILE=/app/data/domains.json
|
||||
RUN mkdir -p /app/data
|
||||
VOLUME ["/app/data"]
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||
CMD wget -qO- http://127.0.0.1:3000/health || exit 1
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
|
||||
Reference in New Issue
Block a user