Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Development Dockerfile - prepares dev environment for live compilation
# supported versions here: https://hub.docker.com/_/rust
ARG ALPINE_VERSION=3.20

FROM rust:alpine${ALPINE_VERSION}

RUN apk add --no-cache musl-dev wget

WORKDIR /redlib

# Pre-download dependencies (will be cached in Docker volume)
COPY Cargo.lock Cargo.toml ./
RUN mkdir -p src && echo "fn main() {}" > src/main.rs && \
cargo build --bin redlib && \
rm -rf src

# Install cargo-watch for automatic recompilation on file changes
RUN cargo install cargo-watch

EXPOSE 8080

# Use cargo-watch to automatically recompile and restart on source changes
CMD ["cargo", "watch", "-x", "run --bin redlib"]

35 changes: 23 additions & 12 deletions compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
# docker-compose -f docker-compose.dev.yml up -d
version: "3.8"
# docker compose -f compose.dev.yaml up
# Development setup - source mounted read-only, build cache in Docker volumes

services:
redlib:
build: .
restart: always
build:
context: .
dockerfile: Dockerfile.dev
container_name: "redlib"
ports:
- 8080:8080 # Specify `127.0.0.1:8080:8080` instead if using a reverse proxy
user: nobody
read_only: true
security_opt:
- no-new-privileges:true
# - seccomp=seccomp-redlib.json
cap_drop:
- ALL
- 8080:8080
volumes:
# Mount source code as read-only - code changes trigger rebuild
- ./src:/redlib/src:ro
- ./templates:/redlib/templates:ro
- ./static:/redlib/static:ro
- ./Cargo.toml:/redlib/Cargo.toml:ro
- ./Cargo.lock:/redlib/Cargo.lock:ro
- ./build.rs:/redlib/build.rs:ro
# Build artifacts stay in Docker volumes (not on your disk)
- redlib-target:/redlib/target
- redlib-cargo:/usr/local/cargo
environment:
- RUST_LOG=debug
networks:
- redlib
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "--tries=1", "http://localhost:8080/settings"]
interval: 5m
timeout: 3s

volumes:
redlib-target:
redlib-cargo:

networks:
redlib: