fix binary/artifact-in-docker errors and uncertainties

This commit is contained in:
2025-11-27 17:59:17 +01:00
parent 598bae7377
commit 87361d6418
5 changed files with 34 additions and 23 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
/target /target
*.env *.env
.DS_Store .DS_Store
web/styles.css

View File

@@ -7,6 +7,7 @@ ARG APP_NAME=arche
FROM rust:${RUST_VERSION}-alpine AS build FROM rust:${RUST_VERSION}-alpine AS build
ARG APP_NAME ARG APP_NAME
WORKDIR /app WORKDIR /app
ENV IN_DOCKER=true
# Install host build dependencies. # Install host build dependencies.
RUN apk add --no-cache clang lld musl-dev git RUN apk add --no-cache clang lld musl-dev git
@@ -58,6 +59,7 @@ RUN adduser \
RUN mkdir -p /app && chown appuser:appuser /app RUN mkdir -p /app && chown appuser:appuser /app
USER appuser USER appuser
WORKDIR /app WORKDIR /app
ENV IN_DOCKER=true
ENV DISCORD_BOT_TOKEN="" ENV DISCORD_BOT_TOKEN=""
ENV DISCORD_SERVER_ID="" ENV DISCORD_SERVER_ID=""

View File

@@ -7,30 +7,30 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=web"); println!("cargo:rerun-if-changed=web");
let os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_else(|_| String::from("unknown")); if std::env::var("IN_DOCKER").is_err() {
let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| String::from("unknown")); let os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_else(|_| String::from("unknown"));
let download_url = match (os.as_str(), arch.as_str()) { let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| String::from("unknown"));
("macos", "aarch64") => { let download_url = match (os.as_str(), arch.as_str()) {
"https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-macos-arm64" ("macos", "aarch64") => {
} "https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-macos-arm64"
("linux", "x86_64") => { }
"https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64" ("linux", "x86_64") => {
} "https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64"
("linux", "aarch64") => { }
"https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-arm64" ("linux", "aarch64") => {
} "https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-arm64"
_ => return Err(format!("Unsupported platform: {} {}", os, arch).into()), }
}; _ => return Err(format!("Unsupported platform: {} {}", os, arch).into()),
};
let out_dir = PathBuf::from(env::var("OUT_DIR")?); let out_dir = PathBuf::from(env::var("OUT_DIR")?);
let tailwind_binary = out_dir.join("tailwind"); let tailwind_binary = out_dir.join("tailwind");
fs::create_dir_all(&out_dir)?; fs::create_dir_all(&out_dir)?;
download_tailwind(&download_url, &tailwind_binary)?; download_tailwind(&download_url, &tailwind_binary)?;
println!("cargo:rustc-env=TAILWIND_BIN={}", tailwind_binary.display());
println!("cargo:rustc-env=TAILWIND_BIN={}", tailwind_binary.display()); run_tailwind(&tailwind_binary)?;
}
run_tailwind(&tailwind_binary)?;
Ok(()) Ok(())
} }

8
readme.txt Normal file
View File

@@ -0,0 +1,8 @@
arche
=====
Regarding /web/styles.css
The styles.css file, which is generated by a standalone Tailwind binary downloaded and executed automatically within build.rs, is to be committed any time it changes, as without it styling will be broken on the frontend part of the page.
This is in contrast to a perhaps expected approach of gitignoring them and just generating them every build; this is incompatible with building docker images in an efficient way, however, as docker exposes no way to mount directories while retaining ability to write files and execute binaries.

2
web/styles.css Normal file

File diff suppressed because one or more lines are too long