Compare commits

...

3 Commits

Author SHA1 Message Date
fa-sharp
594e15a768 add Dockerfile 2026-02-22 02:24:28 -05:00
fa-sharp
13918f65ad ci: remove unnecessary steps when no updates are available 2026-02-20 23:12:20 -05:00
fa-sharp
97c8b6a38d Update README.md 2026-02-20 05:51:00 -05:00
3 changed files with 54 additions and 1 deletions

View File

@@ -70,10 +70,12 @@ jobs:
working-directory: dep-check-test
- name: Check with upgraded dependencies
if: steps.upgrade.outputs.has_updates == 'true'
run: cargo check
working-directory: dep-check-test
- name: Build with upgraded dependencies
if: steps.upgrade.outputs.has_updates == 'true'
run: cargo build
working-directory: dep-check-test
@@ -121,6 +123,7 @@ jobs:
}"
- name: Generate test project without aide
if: steps.upgrade.outputs.has_updates == 'true'
run: |
mkdir -p dep-check-no-aide && cd dep-check-no-aide
cargo generate --path .. --name dep-check-no-aide --vcs none --init \
@@ -132,18 +135,22 @@ jobs:
working-directory: ${{ github.workspace }}
- name: Check without aide (current dependencies)
if: steps.upgrade.outputs.has_updates == 'true'
run: cargo check
working-directory: dep-check-no-aide
- name: Upgrade dependencies (no aide)
if: steps.upgrade.outputs.has_updates == 'true'
run: cargo upgrade --incompatible
working-directory: dep-check-no-aide
- name: Check without aide (upgraded dependencies)
if: steps.upgrade.outputs.has_updates == 'true'
run: cargo check
working-directory: dep-check-no-aide
- name: Build without aide (upgraded dependencies)
if: steps.upgrade.outputs.has_updates == 'true'
run: cargo build
working-directory: dep-check-no-aide

45
Dockerfile Normal file
View 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"]

View File

@@ -10,6 +10,7 @@ A production-ready template for building web services with Rust and Axum.
- **Graceful Shutdown** - Handles SIGTERM and SIGINT signals
- **Plugin Architecture** - Modular app initialization with `axum-app-wrapper`
- **Optional OpenAPI** - API documentation with `aide` (optional)
- **Docker / OCI** - Dockerfile with sensible defaults for quick deployment
## Usage
@@ -75,7 +76,7 @@ In development, you can use the `.env` file to set environment variables.
cargo run
# Run with custom log level
RUST_LOG=debug cargo run
APP_LOG_LEVEL=debug cargo run
# Build for production
cargo build --release