Skip to content

Commit 2ab46b4

Browse files
authored
Merge pull request #40 from encryption4all/dev-docker-setup
Add development Docker setup
2 parents 6916089 + 11f1a70 commit 2ab46b4

5 files changed

Lines changed: 115 additions & 6 deletions

File tree

backend.dev.Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM rust:1.91.0-slim-trixie AS chef
2+
3+
# Install cargo-chef for dependency caching
4+
RUN cargo install cargo-chef cargo-watch
5+
6+
WORKDIR /app
7+
8+
FROM chef AS planner
9+
# Copy source to create recipe
10+
COPY cryptify-back-end/Cargo.toml .
11+
COPY cryptify-back-end/Cargo.lock .
12+
COPY cryptify-back-end/src ./src
13+
RUN cargo chef prepare --recipe-path recipe.json
14+
15+
FROM chef AS builder
16+
17+
ENV ROCKET_PROFILE=debug
18+
19+
# Install system dependencies
20+
RUN apt-get update \
21+
&& apt-get --no-install-recommends install -y libssl-dev pkg-config \
22+
&& rm -rf /var/lib/apt/lists/*
23+
24+
# Build dependencies using recipe (this layer gets cached!)
25+
COPY --from=planner /app/recipe.json recipe.json
26+
RUN cargo chef cook --recipe-path recipe.json
27+
28+
# Copy lockfile and manifest
29+
COPY cryptify-back-end/Cargo.toml .
30+
COPY cryptify-back-end/Cargo.lock .
31+
32+
# Create data directory
33+
RUN mkdir -p /tmp/data
34+
35+
# The actual source will be mounted as a volume
36+
EXPOSE 8000
37+
38+
# Use cargo-watch to rebuild only app code when source changes
39+
CMD ["cargo", "watch", "-x", "run"]

conf/config.dev.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
[global]
2-
server_url = "http://localhost:8080/"
1+
[default]
32
address = "0.0.0.0"
3+
port = 8000
4+
server_url = "http://localhost:8080/"
45
data_dir = "/tmp/data"
56
email_from = "noreply@postguard.local"
67
smtp_url = "mailcrab"
78
smtp_port = 1025
89
# smtp_credentials = ["user", "pw"]
9-
allowed_origins = "^http://localhost:8080$"
10+
allowed_origins = "^https?://(localhost|127\\.0\\.0\\.1)(:[0-9]+)?$"
1011
pkg_url = "https://postguard-main.cs.ru.nl/pkg"

conf/nginx.dev.conf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ http {
1313
server_tokens on;
1414

1515
include /etc/nginx/mime.types;
16-
types {
17-
application/wasm wasm;
18-
}
1916

2017
access_log /dev/fd/1;
2118
error_log /dev/fd/2;

docker-compose.dev.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
services:
2+
nginx:
3+
image: nginx:alpine
4+
container_name: nginx-dev
5+
ports:
6+
- "80:80"
7+
volumes:
8+
- "./conf/nginx.dev.conf:/etc/nginx/nginx.conf:ro"
9+
depends_on:
10+
- backend
11+
- frontend
12+
networks: [default]
13+
14+
frontend:
15+
build:
16+
context: .
17+
dockerfile: frontend.dev.Dockerfile
18+
container_name: frontend-dev
19+
environment:
20+
- REACT_APP_ENV=development
21+
ports:
22+
- "8080:8080"
23+
volumes:
24+
- "./cryptify-front-end/src:/app/src"
25+
- "./cryptify-front-end/public:/app/public"
26+
networks: [default]
27+
28+
backend:
29+
build:
30+
context: .
31+
dockerfile: backend.dev.Dockerfile
32+
container_name: backend-dev
33+
depends_on:
34+
- mailcrab
35+
volumes:
36+
- "./cryptify-back-end/src:/app/src"
37+
- "./cryptify-back-end/templates:/app/templates"
38+
- "./conf/config.dev.toml:/app/config.toml:ro"
39+
ports:
40+
- "8000:8000"
41+
environment:
42+
- ROCKET_CONFIG=config.toml
43+
- RUST_LOG=debug
44+
- RUST_BACKTRACE=1
45+
networks: [default]
46+
47+
mailcrab:
48+
image: marlonb/mailcrab:latest
49+
container_name: mailcrab-dev
50+
ports:
51+
- "1080:1080"
52+
- "1025:1025"
53+
networks: [default]

frontend.dev.Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM node:24-alpine
2+
3+
WORKDIR /app
4+
5+
# Copy package files
6+
COPY cryptify-front-end/package.json .
7+
COPY cryptify-front-end/package-lock.json .
8+
COPY cryptify-front-end/craco.config.js .
9+
COPY cryptify-front-end/tsconfig.json .
10+
COPY cryptify-front-end/.env .
11+
12+
# Install dependencies
13+
RUN npm install --legacy-peer-deps
14+
15+
# The source will be mounted as a volume for hot reloading
16+
EXPOSE 8080
17+
18+
# Start development server
19+
CMD ["npm", "start"]

0 commit comments

Comments
 (0)