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
92 changes: 0 additions & 92 deletions .github/workflows/ci.yml

This file was deleted.

69 changes: 17 additions & 52 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: Docker CI with Enhanced Checks
name: Docker Build and Push

on:
push:
branches: [ "main" ]
branches: [ main ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]
branches: [ main ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
RUST_LOG: info

jobs:
lint-and-test:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -22,30 +22,14 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt, clippy

- name: Rust cache
uses: Swatinem/rust-cache@v2

- name: Check formatting
run: cargo fmt -- --check

- name: Run clippy
run: cargo clippy -- -D warnings

- name: Run tests
run: cargo test

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64
buildkitd-flags: --debug

- name: Log in to Registry
- name: Log in to the Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
Expand All @@ -61,36 +45,17 @@ jobs:
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha

- name: Build and test Docker image
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: false
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
RUST_LOG=info
target: builder
load: true

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Build and push final image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
RUST_LOG=info
platforms: linux/amd64
cache-from: type=gha,scope=${{ github.workflow }}
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
outputs: type=docker,dest=/tmp/image.tar
17 changes: 1 addition & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM rustlang/rust:nightly AS builder


RUN apt-get update && \
apt-get install -y \
pkg-config \
Expand All @@ -15,33 +14,22 @@ RUN apt-get update && \

WORKDIR /usr/src/app


COPY Cargo.toml Cargo.lock* ./


RUN mkdir src && \
echo "fn main() { println!(\"Initializing build...\"); }" > src/main.rs && \
cargo build --release && \
cargo build --tests && \
rm -rf src


COPY src src/


ARG RUST_LOG=info
ENV RUST_LOG=${RUST_LOG}

RUN echo "Building application with RUST_LOG=${RUST_LOG}" && \
cargo build --release && \
cargo test --no-run


FROM debian:bookworm-slim


RUN apt-get update && \
apt-get install -y \
bash \
ca-certificates \
libwebkit2gtk-4.0-37 \
libjavascriptcoregtk-4.0-18 \
Expand All @@ -55,13 +43,10 @@ RUN apt-get update && \
libxdo3 && \
rm -rf /var/lib/apt/lists/*


COPY --from=builder /usr/src/app/target/release/titanium /usr/local/bin/


ENV RUST_LOG=info


COPY <<'EOF' /usr/local/bin/start.sh
#!/bin/bash
echo "Starting Titanium server with RUST_LOG=${RUST_LOG}"
Expand Down
43 changes: 39 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
services:
app:
build: .
image: ${REGISTRY:-ghcr.io}/${IMAGE_NAME:-developerfred/titanium}:${TAG:-latest}
build:
context: .
args:
RUST_LOG: ${RUST_LOG:-debug}
ports:
- "3000:3000"
environment:
- RUST_LOG=info
- RUST_LOG=${RUST_LOG:-debug}
- RUST_BACKTRACE=full
- RUST_LIB_BACKTRACE=1
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "5"
compress: "true"
mode: "non-blocking"
tag: "{{.Name}}"
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 512M
volumes:
- ./logs:/app/logs

test:
build:
Expand All @@ -19,11 +42,23 @@ services:
command: cargo test --all-features -- --nocapture
environment:
- RUST_LOG=debug
- RUST_BACKTRACE=1
- RUST_BACKTRACE=full
- RUST_LIB_BACKTRACE=1
volumes:
- .:/usr/src/app
- cargo-cache:/usr/local/cargo/registry
- ./logs:/app/logs
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "5"
compress: "true"
mode: "non-blocking"
tag: "{{.Name}}"
profiles: ["test"]

volumes:
cargo-cache: {}
cargo-cache: {}
logs:
driver: local
Loading
Loading