fix binary/artifact-in-docker errors and uncertainties
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,3 @@
|
|||||||
/target
|
/target
|
||||||
*.env
|
*.env
|
||||||
.DS_Store
|
.DS_Store
|
||||||
web/styles.css
|
|
||||||
|
|||||||
@@ -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=""
|
||||||
|
|||||||
4
build.rs
4
build.rs
@@ -7,6 +7,7 @@ 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");
|
||||||
|
|
||||||
|
if std::env::var("IN_DOCKER").is_err() {
|
||||||
let os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_else(|_| String::from("unknown"));
|
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 arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| String::from("unknown"));
|
||||||
let download_url = match (os.as_str(), arch.as_str()) {
|
let download_url = match (os.as_str(), arch.as_str()) {
|
||||||
@@ -27,10 +28,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
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
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