Skip to content

Commit

Permalink
[self-host] build keybroker generate_key into the backend binary (#33…
Browse files Browse the repository at this point in the history
…844)

add an extra binary to the self-hosted backend container, so you can

```
docker exec convex-backend ./generate_key $INSTANCE_NAME $INSTANCE_SECRET
```

to create new API keys.

Or if the container isn't running,

```
docker run --rm --entrypoint ./generate_key ghcr.io/get-convex/self-hosted-backend:latest $INSTANCE_NAME $INSTANCE_SECRET
```

GitOrigin-RevId: 04ffcf2bb00f7c4a9b4a16e5ebd9b1e9595d0bf4
  • Loading branch information
ldanilek authored and Convex, Inc. committed Jan 31, 2025
1 parent 2d87a0d commit 88bc56d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 4 additions & 5 deletions self-hosted/Dockerfile.backend
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ COPY . .
RUN --mount=type=cache,target=/convex/npm-packages/common/temp/,sharing=locked --mount=type=cache,target=/convex/target/ --mount=type=cache,target=/usr/local/cargo/git/db --mount=type=cache,target=/usr/local/cargo/registry/ <<EOF
cargo build --release -p local_backend --bin convex-local-backend
cp target/release/convex-local-backend .
cargo build --release -p keybroker --bin generate_key
cp target/release/generate_key .
EOF
ARG debug
RUN if [[ -z "$debug" ]]; then strip ./convex-local-backend; fi
RUN if [[ -z "$debug" ]]; then strip ./convex-local-backend; strip ./generate_key; fi

# Final stage: Creates minimal runtime image with only necessary components
# Uses Ubuntu Noble (24.04) as the base image
Expand All @@ -102,12 +104,9 @@ RUN ln -sf /usr/lib/node_modules/npm/bin/npm-cli.js /usr/bin/npm && \
RUN ln -sf /usr/lib/node_modules/npm/bin/npx-cli.js /usr/bin/npx && \
chmod +x /usr/bin/npx
COPY --from=build --chmod=744 /convex/convex-local-backend .
COPY --from=build --chmod=744 /convex/generate_key .
COPY --chmod=744 self-hosted/run_backend.sh .


RUN chmod +x convex-local-backend
RUN chmod +x run_backend.sh

VOLUME /convex/data

# Set the backend as the executable
Expand Down
3 changes: 2 additions & 1 deletion self-hosted/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ services:
- CONVEX_SITE_ORIGIN=${URL_BASE}:${SITE_PROXY_PORT}
- PORT=${PORT}
- SITE_PROXY_PORT=${SITE_PROXY_PORT}
container_name: convex-local-backend
healthcheck:
test: curl -f http://localhost:3210/version
test: curl -f http://localhost:$${PORT}/version
interval: 5s
start_period: 5s

Expand Down

0 comments on commit 88bc56d

Please sign in to comment.