fix binary/artifact-in-docker errors and uncertainties
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,3 @@
|
||||
/target
|
||||
*.env
|
||||
.DS_Store
|
||||
web/styles.css
|
||||
|
||||
@@ -7,6 +7,7 @@ ARG APP_NAME=arche
|
||||
FROM rust:${RUST_VERSION}-alpine AS build
|
||||
ARG APP_NAME
|
||||
WORKDIR /app
|
||||
ENV IN_DOCKER=true
|
||||
|
||||
# Install host build dependencies.
|
||||
RUN apk add --no-cache clang lld musl-dev git
|
||||
@@ -58,6 +59,7 @@ RUN adduser \
|
||||
RUN mkdir -p /app && chown appuser:appuser /app
|
||||
USER appuser
|
||||
WORKDIR /app
|
||||
ENV IN_DOCKER=true
|
||||
|
||||
ENV DISCORD_BOT_TOKEN=""
|
||||
ENV DISCORD_SERVER_ID=""
|
||||
|
||||
44
build.rs
44
build.rs
@@ -7,30 +7,30 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-changed=web");
|
||||
|
||||
let os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_else(|_| String::from("unknown"));
|
||||
let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| String::from("unknown"));
|
||||
let download_url = match (os.as_str(), arch.as_str()) {
|
||||
("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", "aarch64") => {
|
||||
"https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-arm64"
|
||||
}
|
||||
_ => return Err(format!("Unsupported platform: {} {}", os, arch).into()),
|
||||
};
|
||||
if std::env::var("IN_DOCKER").is_err() {
|
||||
let os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_else(|_| String::from("unknown"));
|
||||
let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| String::from("unknown"));
|
||||
let download_url = match (os.as_str(), arch.as_str()) {
|
||||
("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", "aarch64") => {
|
||||
"https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-arm64"
|
||||
}
|
||||
_ => return Err(format!("Unsupported platform: {} {}", os, arch).into()),
|
||||
};
|
||||
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
|
||||
let tailwind_binary = out_dir.join("tailwind");
|
||||
fs::create_dir_all(&out_dir)?;
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
|
||||
let tailwind_binary = out_dir.join("tailwind");
|
||||
fs::create_dir_all(&out_dir)?;
|
||||
|
||||
download_tailwind(&download_url, &tailwind_binary)?;
|
||||
|
||||
println!("cargo:rustc-env=TAILWIND_BIN={}", tailwind_binary.display());
|
||||
|
||||
run_tailwind(&tailwind_binary)?;
|
||||
download_tailwind(&download_url, &tailwind_binary)?;
|
||||
println!("cargo:rustc-env=TAILWIND_BIN={}", tailwind_binary.display());
|
||||
run_tailwind(&tailwind_binary)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
8
readme.txt
Normal file
8
readme.txt
Normal 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
2
web/styles.css
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user