mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-11 06:53:01 +02:00
feat: HTML default page
This commit is contained in:
parent
0931d77698
commit
d8c03d43f4
10 changed files with 391 additions and 331 deletions
|
@ -18,14 +18,13 @@ ARG LLVM_VERSION=19
|
|||
# Line three: for xx-verify
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
apt-get update && apt-get install -y \
|
||||
apt-get update && apt-get install -y \
|
||||
clang-${LLVM_VERSION} lld-${LLVM_VERSION} pkg-config make jq \
|
||||
curl git \
|
||||
file
|
||||
|
||||
# Create symlinks for LLVM tools
|
||||
RUN <<EOF
|
||||
set -o xtrace
|
||||
# clang
|
||||
ln -s /usr/bin/clang-${LLVM_VERSION} /usr/bin/clang
|
||||
ln -s "/usr/bin/clang++-${LLVM_VERSION}" "/usr/bin/clang++"
|
||||
|
@ -47,7 +46,6 @@ ENV LDDTREE_VERSION=0.3.7
|
|||
|
||||
# Install unpackaged tools
|
||||
RUN <<EOF
|
||||
set -o xtrace
|
||||
curl --retry 5 -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
|
||||
cargo binstall --no-confirm cargo-sbom --version $CARGO_SBOM_VERSION
|
||||
cargo binstall --no-confirm lddtree --version $LDDTREE_VERSION
|
||||
|
@ -61,7 +59,7 @@ ARG TARGETPLATFORM
|
|||
# xx-* are xx-specific meta-packages
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
xx-apt-get install -y \
|
||||
xx-apt-get install -y \
|
||||
xx-c-essentials xx-cxx-essentials pkg-config \
|
||||
liburing-dev
|
||||
|
||||
|
@ -77,7 +75,6 @@ RUN echo "CARGO_INCREMENTAL=0" >> /etc/environment
|
|||
|
||||
# Configure pkg-config
|
||||
RUN <<EOF
|
||||
set -o xtrace
|
||||
echo "PKG_CONFIG_LIBDIR=/usr/lib/$(xx-info)/pkgconfig" >> /etc/environment
|
||||
echo "PKG_CONFIG=/usr/bin/$(xx-info)-pkg-config" >> /etc/environment
|
||||
echo "PKG_CONFIG_ALLOW_CROSS=true" >> /etc/environment
|
||||
|
@ -85,14 +82,12 @@ EOF
|
|||
|
||||
# Configure cc to use clang version
|
||||
RUN <<EOF
|
||||
set -o xtrace
|
||||
echo "CC=clang" >> /etc/environment
|
||||
echo "CXX=clang++" >> /etc/environment
|
||||
EOF
|
||||
|
||||
# Cross-language LTO
|
||||
RUN <<EOF
|
||||
set -o xtrace
|
||||
echo "CFLAGS=-flto" >> /etc/environment
|
||||
echo "CXXFLAGS=-flto" >> /etc/environment
|
||||
# Linker is set to target-compatible clang by xx
|
||||
|
@ -103,7 +98,6 @@ EOF
|
|||
ARG TARGET_CPU=
|
||||
RUN <<EOF
|
||||
set -o allexport
|
||||
set -o xtrace
|
||||
. /etc/environment
|
||||
if [ -n "${TARGET_CPU}" ]; then
|
||||
echo "CFLAGS='${CFLAGS} -march=${TARGET_CPU}'" >> /etc/environment
|
||||
|
@ -121,33 +115,123 @@ FROM toolchain AS builder
|
|||
# Get source
|
||||
COPY . .
|
||||
|
||||
# Conduwuit version info
|
||||
ARG COMMIT_SHA=
|
||||
ARG SHORT_COMMIT_SHA=
|
||||
ARG REMOTE_URL=
|
||||
ARG CONDUWUIT_VERSION_EXTRA=
|
||||
ENV COMMIT_SHA=$COMMIT_SHA
|
||||
ENV SHORT_COMMIT_SHA=$SHORT_COMMIT_SHA
|
||||
ENV REMOTE_URL=$REMOTE_URL
|
||||
ENV CONDUWUIT_VERSION_EXTRA=$CONDUWUIT_VERSION_EXTRA
|
||||
|
||||
# Calculate version info from git if not provided via ARGs
|
||||
# and write all relevant vars to /etc/environment
|
||||
RUN <<'EOF'
|
||||
set -e # Exit on error
|
||||
|
||||
# Use temp variables to store calculated values
|
||||
calculated_commit_sha=""
|
||||
calculated_remote_url=""
|
||||
calculated_version_extra=""
|
||||
|
||||
# --- COMMIT_SHA ---
|
||||
# Calculate COMMIT_SHA if ENV var (from ARG) is empty
|
||||
if [ -z "${COMMIT_SHA}" ]; then
|
||||
# Try to get short commit hash from git
|
||||
calculated_commit_sha=$(git rev-parse HEAD 2>/dev/null || echo "")
|
||||
if [ -n "${calculated_commit_sha}" ]; then
|
||||
echo "COMMIT_SHA='${calculated_commit_sha}'" >> /etc/environment
|
||||
fi
|
||||
else
|
||||
# Ensure ARG-provided value is in /etc/environment
|
||||
echo "COMMIT_SHA='${COMMIT_SHA}'" >> /etc/environment
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "${SHORT_COMMIT_SHA}" ]; then
|
||||
# Try to get short commit hash from git
|
||||
calculated_short_commit_sha=$(git rev-parse --short HEAD 2>/dev/null || echo "")
|
||||
if [ -n "${calculated_short_commit_sha}" ]; then
|
||||
echo "SHORT_COMMIT_SHA='${calculated_short_commit_sha}'" >> /etc/environment
|
||||
fi
|
||||
else
|
||||
# Ensure ARG-provided value is in /etc/environment
|
||||
echo "SHORT_COMMIT_SHA='${SHORT_COMMIT_SHA}'" >> /etc/environment
|
||||
fi
|
||||
|
||||
# --- REMOTE_URL ---
|
||||
# Calculate REMOTE_URL if ENV var (from ARG) is empty
|
||||
if [ -z "${REMOTE_URL}" ]; then
|
||||
# Try to get remote origin URL from git
|
||||
remote_url_raw=$(git config --get remote.origin.url 2>/dev/null || echo "")
|
||||
if [ -n "${remote_url_raw}" ]; then
|
||||
# Transform git URL (SSH or HTTPS) to web URL
|
||||
if [[ $remote_url_raw == "https://"* ]]; then
|
||||
# Already HTTPS, just remove .git suffix
|
||||
calculated_remote_url=$(echo "$remote_url_raw" | sed 's/\.git$//')
|
||||
else
|
||||
# Convert SSH URL to HTTPS URL
|
||||
calculated_remote_url=$(echo "$remote_url_raw" | sed 's/\.git$//' | sed 's/:/\//' | sed 's/^git@/https:\/\//')
|
||||
fi
|
||||
|
||||
# Write calculated web URL if transformation was successful
|
||||
if [ -n "${calculated_remote_url}" ]; then
|
||||
echo "REMOTE_URL='${calculated_remote_url}'" >> /etc/environment
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# Ensure ARG-provided value is in /etc/environment (assume it's a valid web URL)
|
||||
echo "REMOTE_URL='${REMOTE_URL}'" >> /etc/environment
|
||||
# Use provided value for REMOTE_COMMIT_URL calculation below
|
||||
calculated_remote_url="${REMOTE_URL}"
|
||||
fi
|
||||
|
||||
# --- Determine effective values for subsequent calculations ---
|
||||
# Use ENV var value if set (from ARG), otherwise use calculated value
|
||||
effective_commit_sha="${COMMIT_SHA:-$calculated_commit_sha}"
|
||||
effective_short_commit_sha="${SHORT_COMMIT_SHA:-$calculated_short_commit_sha}"
|
||||
effective_remote_url="${REMOTE_URL:-$calculated_remote_url}"
|
||||
|
||||
# --- REMOTE_COMMIT_URL ---
|
||||
# Calculate and write REMOTE_COMMIT_URL if both components are available
|
||||
if [ -z "${REMOTE_COMMIT_URL}" ] && [ -n "${effective_remote_url}" ] && [ -n "${effective_commit_sha}" ]; then
|
||||
echo "REMOTE_COMMIT_URL='${effective_remote_url}/commit/${effective_commit_sha}'" >> /etc/environment
|
||||
else
|
||||
# Ensure ARG-provided value is in /etc/environment
|
||||
echo "REMOTE_COMMIT_URL='${REMOTE_COMMIT_URL}'" >> /etc/environment
|
||||
fi
|
||||
|
||||
# --- CONDUWUIT_VERSION_EXTRA ---
|
||||
# Calculate CONDUWUIT_VERSION_EXTRA if ENV var (from ARG) is empty
|
||||
if [ -z "${CONDUWUIT_VERSION_EXTRA}" ]; then
|
||||
# Use the effective short commit sha, fallback to "unknown revision"
|
||||
calculated_version_extra="${effective_short_commit_sha:-unknown revision}"
|
||||
# Handle case where commit sha calculation failed and ARG wasn't set
|
||||
if [ -z "${calculated_version_extra}" ]; then
|
||||
calculated_version_extra="unknown revision"
|
||||
fi
|
||||
echo "CONDUWUIT_VERSION_EXTRA='${calculated_version_extra}'" >> /etc/environment
|
||||
else
|
||||
# Ensure ARG-provided value is in /etc/environment
|
||||
echo "CONDUWUIT_VERSION_EXTRA='${CONDUWUIT_VERSION_EXTRA}'" >> /etc/environment
|
||||
fi
|
||||
|
||||
EOF
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
# Verify environment configuration
|
||||
RUN cat /etc/environment
|
||||
RUN xx-cargo --print-target-triple
|
||||
|
||||
# Conduwuit version info
|
||||
ARG GIT_COMMIT_HASH=
|
||||
ARG GIT_COMMIT_HASH_SHORT=
|
||||
ARG GIT_REMOTE_URL=
|
||||
ARG GIT_REMOTE_COMMIT_URL=
|
||||
ARG CONDUWUIT_VERSION_EXTRA=
|
||||
ARG CONTINUWUITY_VERSION_EXTRA=
|
||||
ENV GIT_COMMIT_HASH=$GIT_COMMIT_HASH
|
||||
ENV GIT_COMMIT_HASH_SHORT=$GIT_COMMIT_HASH_SHORT
|
||||
ENV GIT_REMOTE_URL=$GIT_REMOTE_URL
|
||||
ENV GIT_REMOTE_COMMIT_URL=$GIT_REMOTE_COMMIT_URL
|
||||
ENV CONDUWUIT_VERSION_EXTRA=$CONDUWUIT_VERSION_EXTRA
|
||||
ENV CONTINUWUITY_VERSION_EXTRA=$CONTINUWUITY_VERSION_EXTRA
|
||||
|
||||
|
||||
# Build the binary
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/usr/local/cargo/git/db \
|
||||
--mount=type=cache,target=/app/target,id=cargo-target-${TARGETPLATFORM} \
|
||||
--mount=type=cache,target=/app/target \
|
||||
bash <<'EOF'
|
||||
set -o allexport
|
||||
set -o xtrace
|
||||
. /etc/environment
|
||||
TARGET_DIR=($(cargo metadata --no-deps --format-version 1 | \
|
||||
jq -r ".target_directory"))
|
||||
|
@ -168,7 +252,6 @@ EOF
|
|||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/usr/local/cargo/git/db \
|
||||
bash <<'EOF'
|
||||
set -o xtrace
|
||||
mkdir /out/sbom
|
||||
typeset -A PACKAGES
|
||||
for BINARY in /out/sbin/*; do
|
||||
|
@ -187,7 +270,6 @@ EOF
|
|||
|
||||
# Extract dynamically linked dependencies
|
||||
RUN <<EOF
|
||||
set -o xtrace
|
||||
mkdir /out/libs
|
||||
mkdir /out/libs-root
|
||||
for BINARY in /out/sbin/*; do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue