Merge pull request #2341 from Marjani/main

Add Dockerfile and docker-compose.yml
This commit is contained in:
dangered wolf
2026-08-20 12:34:36 -04:00
committed by GitHub
4 changed files with 95 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
.env*
!.env.example
+40
View File
@@ -0,0 +1,40 @@
FROM node:24-bookworm-slim AS base
WORKDIR /app
# FxEmbed's build script shells out to git for release metadata.
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates git \
&& rm -rf /var/lib/apt/lists/*
FROM base AS deps
COPY package.json package-lock.json ./
COPY packages/atmosphere/package.json ./packages/atmosphere/package.json
RUN npm ci
FROM base AS build
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN test -f wrangler.toml || cp wrangler.example.toml wrangler.toml
RUN test -f .env || cp .env.example .env
RUN npm run build:atmosphere && npm run build-local
FROM base AS runtime
ENV NODE_ENV=production
ENV WRANGLER_SEND_METRICS=false
RUN groupadd --gid 1001 fxembed \
&& useradd --uid 1001 --gid fxembed --home-dir /app --no-create-home --shell /usr/sbin/nologin fxembed
COPY --from=build --chown=fxembed:fxembed /app /app
RUN chown fxembed:fxembed /app
EXPOSE 8787
USER fxembed
CMD ["npx", "wrangler", "dev", "./dist/worker.js", "--local", "--ip", "0.0.0.0", "--port", "8787"]
+38
View File
@@ -35,6 +35,44 @@
## [Self-Hosting Guide](https://docs.fxembed.com/deployment)
## Docker
FxEmbed is a Cloudflare Worker, so the Docker image runs the local Workers runtime through Wrangler rather than starting a plain Node.js server. The image uses `node:24-bookworm-slim` because Wrangler's `workerd` binary is glibc-linked and does not run reliably on Alpine/musl.
Before building, copy and edit the local configuration files if you need custom domains, branding, or credentials:
```bash
cp .env.example .env
cp wrangler.example.toml wrangler.toml
cp branding.example.json branding.json
```
Build and run with Docker Compose:
```bash
docker compose up -d --build
```
The worker listens on `http://localhost:8787`. Because FxEmbed routes by the `Host` header, test a specific realm like this:
```bash
curl -H "Host: fxtwitter.com" -H "User-Agent: Discordbot/2.0" "http://localhost:8787/user/status/123"
```
You can also open `http://localhost:8787/` without a `Host` header to see the local realm prefixes.
Environment variables from `.env` are bundled during the Docker build, so rebuild the image after changing domain lists or other build-time configuration:
```bash
docker compose up -d --build
```
Runtime secrets such as `CREDENTIAL_KEY` and `EXCEPTION_DISCORD_WEBHOOK` can be supplied through your shell or Compose `.env` file. Stop the service with:
```bash
docker compose down
```
**Licensed under the permissive MIT license. Feel free to send a pull request!**
## Star History
+15
View File
@@ -0,0 +1,15 @@
services:
fxembed:
build:
context: .
dockerfile: Dockerfile
image: fxembed:slim
container_name: fxembed
restart: unless-stopped
ports:
- "8787:8787"
environment:
NODE_ENV: production
WRANGLER_SEND_METRICS: "false"
CREDENTIAL_KEY: ${CREDENTIAL_KEY:-}
EXCEPTION_DISCORD_WEBHOOK: ${EXCEPTION_DISCORD_WEBHOOK:-}