-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docker): unify mostro and relay compose
also improve docker image and ergonomics
- Loading branch information
Showing
10 changed files
with
149 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
docker-build: | ||
@set -o pipefail; \ | ||
cd docker && \ | ||
set -a && source .env && set +a && \ | ||
mkdir -p config/lnd && \ | ||
echo "Checking LND files..." && \ | ||
echo "LND_CERT_FILE=$${LND_CERT_FILE}" && \ | ||
echo "LND_MACAROON_FILE=$${LND_MACAROON_FILE}" && \ | ||
if [ ! -f "$${LND_CERT_FILE}" ]; then \ | ||
echo "Error: LND cert file not found at: $${LND_CERT_FILE}"; \ | ||
exit 1; \ | ||
fi && \ | ||
if [ ! -f "$${LND_MACAROON_FILE}" ]; then \ | ||
echo "Error: LND macaroon file not found at: $${LND_MACAROON_FILE}"; \ | ||
exit 1; \ | ||
fi && \ | ||
echo "Copying LND cert and macaroon to docker config" && \ | ||
cp -v $${LND_CERT_FILE} config/lnd/tls.cert && \ | ||
cp -v $${LND_MACAROON_FILE} config/lnd/admin.macaroon && \ | ||
echo "Building docker image" && \ | ||
docker compose build | ||
|
||
docker-up: | ||
@set -o pipefail; \ | ||
cd docker && \ | ||
echo "Copying Nostr relay config" && \ | ||
mkdir -p config/relay && \ | ||
cp -v ./relay_config.toml config/relay/config.toml && \ | ||
echo "Starting services" && \ | ||
docker compose up -d | ||
|
||
docker-relay-up: | ||
@set -o pipefail; \ | ||
cd docker && \ | ||
echo "Copying Nostr relay config" && \ | ||
mkdir -p config/relay && \ | ||
cp -v ./relay_config.toml config/relay/config.toml && \ | ||
echo "Starting Nostr relay" && \ | ||
docker compose up -d nostr-relay | ||
|
||
docker-down: | ||
@set -o pipefail; \ | ||
cd docker && \ | ||
docker compose down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# LND TLS certificate and macaroon files (required) | ||
LND_CERT_FILE= | ||
LND_MACAROON_FILE= | ||
|
||
# Port for local relay | ||
MOSTRO_RELAY_LOCAL_PORT=7000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,50 @@ | ||
# Build stage | ||
FROM rust:1.81 AS builder | ||
FROM rust:1.82 AS builder | ||
|
||
# Install build dependencies | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends cmake build-essential libsqlite3-dev pkg-config libssl-dev protobuf-compiler && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
# Set working directory | ||
WORKDIR /mostro | ||
|
||
# Copy Cargo.toml and Cargo.lock to leverage Docker cache | ||
COPY Cargo.toml Cargo.lock ./ | ||
RUN cargo fetch | ||
|
||
# Copy source code | ||
COPY . . | ||
|
||
# Install build dependencies | ||
RUN apt-get update && \ | ||
apt-get install -y cmake build-essential libsqlite3-dev pkg-config libssl-dev protobuf-compiler | ||
|
||
# Build the project in release mode | ||
RUN cargo build --release | ||
|
||
# Production stage | ||
FROM debian:bookworm-slim | ||
|
||
# Install dependencies | ||
RUN apt-get update && apt-get install -y --reinstall ca-certificates | ||
|
||
# Add a non-root user | ||
RUN useradd -m mostrouser | ||
|
||
# Copy built binary from build stage | ||
COPY --from=builder /mostro/target/release/mostrod /usr/local/bin/mostrod | ||
|
||
WORKDIR /mostro | ||
WORKDIR /home/mostrouser | ||
|
||
# Copy settings and empty database | ||
COPY --chown=mostrouser:mostrouser ./docker/settings.docker.toml ./docker/empty.mostro.db ./ | ||
COPY ./docker/settings.docker.toml ./docker/empty.mostro.db ./ | ||
|
||
# Copy start script | ||
COPY --chown=mostrouser:mostrouser ./docker/start.sh ./start.sh | ||
COPY ./docker/start.sh ./start.sh | ||
RUN chmod +x ./start.sh | ||
|
||
# Add a non-root user and switch to it | ||
RUN useradd -m mostrouser | ||
RUN chown -R mostrouser:mostrouser /home/mostrouser | ||
|
||
# Switch to non-root user | ||
USER mostrouser | ||
|
||
# Start mostro (copy settings and database if it's not created yet) | ||
ENTRYPOINT ["./start.sh"] | ||
CMD ["./start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.