TLS no longer depends on NODE_ENV: the TLS_* variables win, else certs/ is used whenever it exists (the container's /app/certs mount lands there too), and TLS_DISABLED=1 is the only way to serve plain HTTP with a certificate present. The plain-HTTP redirect listener now starts whenever TLS is on, not only in development, and HTTP_REDIRECT_PORT replaces DEV_HTTP_PORT. The installer writes TLS_DISABLED=1 for --no-https, and the health check follows the same rule.
39 lines
1.4 KiB
Docker
39 lines
1.4 KiB
Docker
FROM oven/bun:1.4.3-debian
|
|
|
|
LABEL org.opencontainers.image.title="Cobble" \
|
|
org.opencontainers.image.description="A self-hosted crew of small AI worker bots." \
|
|
org.opencontainers.image.source="https://github.com/Moduletrace/cobble" \
|
|
org.opencontainers.image.licenses="MIT"
|
|
|
|
# openssl generates the local CA and certificate the installer serves HTTPS
|
|
# with (`src/scripts/generate-local-certs.ts`).
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends curl bash nano wget zip unzip openssl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
ENV NODE_ENV=production
|
|
# Everything that must survive an update lives on the /data volume:
|
|
# the database, media, computers' home directories
|
|
ENV DATA_DIR=/data
|
|
ENV DB_DIR=/data/db
|
|
ENV BUN_FEATURE_FLAG_DISABLE_STREAMING_INSTALL=1
|
|
|
|
WORKDIR /app
|
|
|
|
RUN echo 'alias ll="ls -laF"' >/root/.bashrc
|
|
|
|
COPY package.json bun.lock ./
|
|
# Local packages the lockfile installs from (`file:` dependencies)
|
|
COPY packages ./packages
|
|
RUN bun install --frozen-lockfile
|
|
|
|
COPY . /app/.
|
|
|
|
COPY entrypoint.sh /entrypoint.sh
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
|
CMD if [ -z "$TLS_DISABLED" ] && ( [ -n "$TLS_CERT_FILE" ] || [ -f /app/certs/server.crt ] ); then curl -fsSk "https://localhost:${PORT:-7227}/api/health" || exit 1; else curl -fsS "http://localhost:${PORT:-7227}/api/health" || exit 1; fi
|
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|