-
Notifications
You must be signed in to change notification settings - Fork 0
build: optimize docker build and update dependencies #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,35 @@ | ||
| # Build artifacts | ||
| target/ | ||
| .git/* | ||
| .github/* | ||
| docs/* | ||
| Dockerfile | ||
| compose.yml | ||
|
|
||
| # Git & CI | ||
| .git/ | ||
| .github/ | ||
| .gitignore | ||
| .devcontainer/ | ||
|
|
||
| # Documentation | ||
| docs/ | ||
| website/ | ||
| README.md | ||
| README-fr.md | ||
| .dockerignore | ||
| exctractor.js | ||
| README-en.md | ||
| DISCLAIMER.md | ||
| DISCLAIMER-fr.md | ||
| SECURITY.md | ||
| LICENCE | ||
|
|
||
| # Docker files (not needed inside the build context) | ||
| docker/ | ||
|
|
||
| # Nix | ||
| flake.nix | ||
| flake.lock | ||
|
|
||
| # Scripts & config examples | ||
| scripts/ | ||
| Cross.toml | ||
| ygege.yml | ||
| ygege-en.yml | ||
| exctractor.js | ||
|
|
||
| # Tests | ||
| tests/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,15 @@ RUN if [ "${SKIP_UPX}" = "0" ]; then \ | |
|
|
||
| WORKDIR /usr/src/app | ||
|
|
||
| # Copy project files | ||
| # Cache Cargo dependencies separately from source code. | ||
| # This layer is only rebuilt when Cargo.toml or Cargo.lock change. | ||
| COPY Cargo.toml Cargo.lock ./ | ||
| RUN mkdir src && echo "fn main() {}" > src/main.rs \ | ||
| && BUILD_COMMIT=cache BUILD_DATE=cache BUILD_BRANCH=cache \ | ||
| cargo build --release \ | ||
| && rm -rf src | ||
|
|
||
| # Copy project files and build | ||
| COPY . . | ||
|
Comment on lines
+45
to
46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -e
if [ -f .dockerignore ]; then
echo ".dockerignore found"
echo
sed -n '1,200p' .dockerignore
echo
echo "Relevant ignore rules:"
rg -n '^(target/|\.git/|\.cargo/)' .dockerignore || true
else
echo ".dockerignore is missing"
fiRepository: UwUDev/ygege Length of output: 80 Add The dependency-cache split requires a root Create 🤖 Prompt for AI Agents |
||
|
|
||
| # Build the project | ||
|
|
@@ -56,10 +64,10 @@ ARG BUILD_DATE=unknown | |
| ARG BUILD_BRANCH=unknown | ||
|
|
||
| # Install runtime dependencies | ||
| RUN apt-get update && apt-get install -y \ | ||
| adduser \ | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| ca-certificates \ | ||
| curl \ | ||
| passwd \ | ||
|
Gauvino marked this conversation as resolved.
|
||
| && apt-get clean autoclean --yes \ | ||
|
Gauvino marked this conversation as resolved.
|
||
| && apt-get autoremove --yes \ | ||
| && rm -rf /var/cache/apt/archives* /var/lib/apt/lists/* | ||
|
|
@@ -69,18 +77,14 @@ WORKDIR /app | |
| # Copy the built binary from the build stage | ||
| COPY --from=builder /usr/src/app/target/release/ygege /app/ygege | ||
|
|
||
| RUN chmod +x /app/ygege | ||
|
|
||
| # Create necessary directories | ||
| RUN mkdir -p /app/sessions | ||
|
|
||
| # Create non-root user with specific UID/GID for better compatibility | ||
| # Using UID/GID 10001 to avoid conflicts with host systems | ||
| # --no-log-init: Prevents large UID values from causing issues | ||
| # --system: Creates a system user without password | ||
| # --shell /sbin/nologin: Prevents login shell access for security | ||
| RUN addgroup --gid 10001 --system ygege \ | ||
| && adduser --uid 10001 --system --ingroup ygege --home /home/ygege --shell /sbin/nologin ygege \ | ||
| RUN chmod +x /app/ygege \ | ||
| && mkdir -p /app/sessions \ | ||
| && groupadd --gid 10001 --system ygege \ | ||
| && useradd --uid 10001 --system --gid ygege --home-dir /home/ygege --shell /sbin/nologin --no-log-init ygege \ | ||
| && mkdir -p /home/ygege \ | ||
| && chown -R ygege:ygege /app /home/ygege | ||
|
|
||
| VOLUME ["/app/sessions"] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.