diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8e6aaeb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.DS_Store +._* +target +*.log +logs +inferno.toml +node_modules diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml deleted file mode 100644 index e6ae294..0000000 --- a/.github/workflows/clippy.yml +++ /dev/null @@ -1,12 +0,0 @@ -on: [push] -name: Clippy -# Fail on all warnings, including clippy lints. -env: - RUSTFLAGS: "-Dwarnings" -jobs: - clippy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Run Clippy - run: cargo clippy --all-targets --all-features diff --git a/README.md b/README.md index 278b7c5..dbf54e0 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,4 @@ Inferno is a decentralized alternative to Discord. Inferno is licensed under GPLv3. +Dockerfiles linted using [hadolint](https://github.com/hadolint/hadolint). diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..916f6ab --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +services: + server: + restart: unless-stopped + build: + context: ./server/ + dockerfile: dev.Dockerfile + ports: + - "3001:3001" + volumes: + - ./server:/app + - .git:/app/.git diff --git a/server/dev.Dockerfile b/server/dev.Dockerfile new file mode 100644 index 0000000..ee2c025 --- /dev/null +++ b/server/dev.Dockerfile @@ -0,0 +1,7 @@ +FROM rust:1.82.0-alpine3.20 +RUN apk add --no-cache musl-dev=1.2.5-r0 git=2.45.2-r0 +RUN cargo install cargo-watch --locked --version 8.5.3 +WORKDIR /app +RUN git config --global --add safe.directory /app +EXPOSE 3001 +CMD ["cargo", "watch", "-x", "run"] \ No newline at end of file diff --git a/server/prod.Dockerfile b/server/prod.Dockerfile new file mode 100644 index 0000000..c55ac8b --- /dev/null +++ b/server/prod.Dockerfile @@ -0,0 +1,27 @@ +# Build from /, not /server. +# Use cargo chef to cache built dependencies. +FROM rust:1.82.0-alpine3.20 AS chef +RUN apk add --no-cache musl-dev=1.2.5-r0 git=2.45.2-r0 +RUN cargo install cargo-chef --locked --version 0.1.68 +WORKDIR /app +RUN git config --global --add safe.directory /app + +FROM chef AS planner +COPY server/Cargo.toml . +COPY server/Cargo.lock . +RUN cargo chef prepare --recipe-path recipe.json + +FROM chef AS builder +COPY --from=planner /app/recipe.json recipe.json +RUN cargo chef cook --release --recipe-path recipe.json +COPY server . +COPY .git .git +RUN cargo build --release +RUN strip target/release/inferno + +# Multi-stage build to minimize container size +FROM alpine:3.20 +WORKDIR /app +COPY --from=builder /app/target/release/inferno . +EXPOSE 3001 +CMD ["/app/inferno"] \ No newline at end of file