Compare commits
3 Commits
97854359bf
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
594e15a768 | ||
|
|
13918f65ad | ||
|
|
97c8b6a38d |
7
.github/workflows/dependency-check.yml
vendored
7
.github/workflows/dependency-check.yml
vendored
@@ -70,10 +70,12 @@ jobs:
|
|||||||
working-directory: dep-check-test
|
working-directory: dep-check-test
|
||||||
|
|
||||||
- name: Check with upgraded dependencies
|
- name: Check with upgraded dependencies
|
||||||
|
if: steps.upgrade.outputs.has_updates == 'true'
|
||||||
run: cargo check
|
run: cargo check
|
||||||
working-directory: dep-check-test
|
working-directory: dep-check-test
|
||||||
|
|
||||||
- name: Build with upgraded dependencies
|
- name: Build with upgraded dependencies
|
||||||
|
if: steps.upgrade.outputs.has_updates == 'true'
|
||||||
run: cargo build
|
run: cargo build
|
||||||
working-directory: dep-check-test
|
working-directory: dep-check-test
|
||||||
|
|
||||||
@@ -121,6 +123,7 @@ jobs:
|
|||||||
}"
|
}"
|
||||||
|
|
||||||
- name: Generate test project without aide
|
- name: Generate test project without aide
|
||||||
|
if: steps.upgrade.outputs.has_updates == 'true'
|
||||||
run: |
|
run: |
|
||||||
mkdir -p dep-check-no-aide && cd dep-check-no-aide
|
mkdir -p dep-check-no-aide && cd dep-check-no-aide
|
||||||
cargo generate --path .. --name dep-check-no-aide --vcs none --init \
|
cargo generate --path .. --name dep-check-no-aide --vcs none --init \
|
||||||
@@ -132,18 +135,22 @@ jobs:
|
|||||||
working-directory: ${{ github.workspace }}
|
working-directory: ${{ github.workspace }}
|
||||||
|
|
||||||
- name: Check without aide (current dependencies)
|
- name: Check without aide (current dependencies)
|
||||||
|
if: steps.upgrade.outputs.has_updates == 'true'
|
||||||
run: cargo check
|
run: cargo check
|
||||||
working-directory: dep-check-no-aide
|
working-directory: dep-check-no-aide
|
||||||
|
|
||||||
- name: Upgrade dependencies (no aide)
|
- name: Upgrade dependencies (no aide)
|
||||||
|
if: steps.upgrade.outputs.has_updates == 'true'
|
||||||
run: cargo upgrade --incompatible
|
run: cargo upgrade --incompatible
|
||||||
working-directory: dep-check-no-aide
|
working-directory: dep-check-no-aide
|
||||||
|
|
||||||
- name: Check without aide (upgraded dependencies)
|
- name: Check without aide (upgraded dependencies)
|
||||||
|
if: steps.upgrade.outputs.has_updates == 'true'
|
||||||
run: cargo check
|
run: cargo check
|
||||||
working-directory: dep-check-no-aide
|
working-directory: dep-check-no-aide
|
||||||
|
|
||||||
- name: Build without aide (upgraded dependencies)
|
- name: Build without aide (upgraded dependencies)
|
||||||
|
if: steps.upgrade.outputs.has_updates == 'true'
|
||||||
run: cargo build
|
run: cargo build
|
||||||
working-directory: dep-check-no-aide
|
working-directory: dep-check-no-aide
|
||||||
|
|
||||||
|
|||||||
45
Dockerfile
Normal file
45
Dockerfile
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# Image versions (can be overridden by args when building)
|
||||||
|
ARG RUST_VERSION=1.90
|
||||||
|
ARG DEBIAN_VERSION=bookworm
|
||||||
|
|
||||||
|
### Build server ###
|
||||||
|
FROM rust:${RUST_VERSION}-slim-${DEBIAN_VERSION} AS build
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy all necessary files to build the server
|
||||||
|
COPY Cargo.lock Cargo.toml ./
|
||||||
|
COPY ./src ./src
|
||||||
|
# COPY ./migrations ./migrations
|
||||||
|
# etc...
|
||||||
|
|
||||||
|
ARG pkg={{project-name}}
|
||||||
|
|
||||||
|
RUN --mount=type=cache,id=rust_target,target=/app/target \
|
||||||
|
--mount=type=cache,id=cargo_registry,target=/usr/local/cargo/registry \
|
||||||
|
--mount=type=cache,id=cargo_git,target=/usr/local/cargo/git \
|
||||||
|
set -eux; \
|
||||||
|
cargo build --package $pkg --release --locked; \
|
||||||
|
objcopy --compress-debug-sections target/release/$pkg ./run-server
|
||||||
|
|
||||||
|
|
||||||
|
### Run server ###
|
||||||
|
FROM debian:${DEBIAN_VERSION}-slim AS run
|
||||||
|
|
||||||
|
# Create non-root user
|
||||||
|
ARG UID=10001
|
||||||
|
RUN adduser \
|
||||||
|
--disabled-password \
|
||||||
|
--gecos "" \
|
||||||
|
--home "/home/appuser" \
|
||||||
|
--shell "/sbin/nologin" \
|
||||||
|
--uid "${UID}" \
|
||||||
|
appuser
|
||||||
|
USER appuser
|
||||||
|
|
||||||
|
# Copy server binary
|
||||||
|
COPY --from=build --chown=appuser /app/run-server /usr/local/bin/
|
||||||
|
|
||||||
|
# Run server
|
||||||
|
WORKDIR /app
|
||||||
|
ENV {{env_prefix}}_HOST=0.0.0.0
|
||||||
|
CMD ["run-server"]
|
||||||
@@ -10,6 +10,7 @@ A production-ready template for building web services with Rust and Axum.
|
|||||||
- **Graceful Shutdown** - Handles SIGTERM and SIGINT signals
|
- **Graceful Shutdown** - Handles SIGTERM and SIGINT signals
|
||||||
- ️**Plugin Architecture** - Modular app initialization with `axum-app-wrapper`
|
- ️**Plugin Architecture** - Modular app initialization with `axum-app-wrapper`
|
||||||
- **Optional OpenAPI** - API documentation with `aide` (optional)
|
- **Optional OpenAPI** - API documentation with `aide` (optional)
|
||||||
|
- **Docker / OCI** - Dockerfile with sensible defaults for quick deployment
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -75,7 +76,7 @@ In development, you can use the `.env` file to set environment variables.
|
|||||||
cargo run
|
cargo run
|
||||||
|
|
||||||
# Run with custom log level
|
# Run with custom log level
|
||||||
RUST_LOG=debug cargo run
|
APP_LOG_LEVEL=debug cargo run
|
||||||
|
|
||||||
# Build for production
|
# Build for production
|
||||||
cargo build --release
|
cargo build --release
|
||||||
|
|||||||
Reference in New Issue
Block a user