Skip to content

Commit

Permalink
Build payjoin-directory with Docker
Browse files Browse the repository at this point in the history
Include a docker-compose.yml template to run
- payjoin-directory
- redis
- nginx
- certbot

in a valid configuration.

Close #143
  • Loading branch information
DanGould committed Dec 5, 2024
1 parent bba701d commit 211477b
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
37 changes: 37 additions & 0 deletions payjoin-directory/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Use the official Rust image as the builder
FROM --platform=linux/amd64 rust:1.75-slim as builder

WORKDIR /usr/src/payjoin-directory

# Install cross-compilation dependencies
RUN apt-get update && \
apt-get install -y \
build-essential \
musl-tools \
musl-dev \
pkg-config \
gcc-multilib \
&& rm -rf /var/lib/apt/lists/*

# Set the linker
ENV CC_x86_64_unknown_linux_musl=musl-gcc
ENV AR_x86_64_unknown_linux_musl=ar

# Add the x86_64-unknown-linux-musl target
RUN rustup target add x86_64-unknown-linux-musl

# Copy the manifest and source code
COPY payjoin-directory/Cargo.toml ./
COPY payjoin-directory/src/ ./src/

# Build the binary
RUN cargo build --release --target x86_64-unknown-linux-musl

# Create final minimal image
FROM --platform=linux/amd64 alpine:latest

# Copy the binary from builder
COPY --from=builder /usr/src/payjoin-directory/target/x86_64-unknown-linux-musl/release/payjoin-directory ./

# Run the binary
ENTRYPOINT ["./payjoin-directory"]
55 changes: 55 additions & 0 deletions payjoin-directory/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: '3.8'

services:
nginx:
image: nginx:latest
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/logs:/var/log/nginx
- ./nginx/conf.d:/etc/nginx/conf.d
- ./nginx/certs:/etc/ssl/certs
- ./nginx/html:/var/www/html
networks:
- payjoin-network

certbot:
image: certbot/certbot
volumes:
- ./nginx/certs:/etc/letsencrypt
- ./nginx/html:/var/www/html
entrypoint: /bin/sh -c 'trap exit TERM; while :; do certbot renew --webroot -w /var/www/html --deploy-hook "nginx -s reload"; sleep 12h & wait $${!}; done;'
depends_on:
- nginx
networks:
- payjoin-network

payjoin-directory:
image: dangould/payjoin-directory:0.0.1-rc0
environment:
RUST_LOG: "trace"
PJ_DB_HOST: "redis:6379"
PJ_DIR_PORT: "8080"
ports:
- "8080:8080"
depends_on:
- redis
networks:
- payjoin-network

redis:
image: redis:latest
ports:
- "6379:6379"
volumes:
- redis-data:/data
networks:
- payjoin-network

networks:
payjoin-network:
driver: bridge

volumes:
redis-data:

0 comments on commit 211477b

Please sign in to comment.