Skip to content

Commit 8ae83e8

Browse files
setup web client (#7)
1 parent a33b689 commit 8ae83e8

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
[dependencies]
77
anyhow = "1.0.95"
88
clap = { version = "4.5.27", features = ["derive"] }
9-
bedrock = { git = "http://github.com/basalt-rs/bedrock.git", rev = "90122c8", features = ["tokio"] }
9+
bedrock = { git = "http://github.com/basalt-rs/bedrock.git", rev = "f8ce557", features = ["tokio"] }
1010
tokio = { version = "1.43.0", features = ["full"] }
1111
lazy_static = "1.5.0"
1212
tera = "1.20.0"

data/basalt.Dockerfile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
FROM rust:1.84 as basalt-compilation
22

3+
RUN touch /redocly
4+
RUN chmod +x /redocly
5+
ENV PATH=/:$PATH
36
RUN git clone https://github.com/basalt-rs/basalt-server
47

58
WORKDIR /basalt-server
69

7-
RUN cargo build --release
10+
# TODO: remove
11+
RUN git checkout optional-docs
12+
RUN cargo build --release --no-default-features
13+
14+
{% if web_client %}
15+
FROM node:22 as web-compilation
16+
17+
RUN git clone https://github.com/basalt-rs/basalt /basalt
18+
19+
# TODO: Remove
20+
WORKDIR /basalt
21+
# TODO: Remove
22+
RUN git checkout no-ssr
23+
24+
WORKDIR /basalt/client
25+
RUN npm ci
26+
RUN npm run build
27+
{% endif %}
828

929
# DO NOT EDIT UNLESS YOU KNOW WHAT YOU'RE DOING
1030
FROM fedora:rawhide as setup
@@ -20,11 +40,18 @@ FROM setup as execution
2040
WORKDIR /execution
2141

2242
COPY --from=basalt-compilation /basalt-server/target/release/basalt-server .
43+
{% if web_client %}
44+
COPY --from=web-compilation /basalt/client/out ./web/
45+
{% endif %}
2346

2447
COPY config.toml .
2548
COPY entrypoint.sh .
2649
RUN chmod +x ./entrypoint.sh
2750

2851
EXPOSE 9090
2952
ENTRYPOINT [ "./entrypoint.sh" ]
53+
{% if web_client %}
54+
CMD [ "./basalt-server", "run", "--port", "9090", "./config.toml", "-w", "./web/" ]
55+
{% else %}
3056
CMD [ "./basalt-server", "run", "--port", "9090", "./config.toml" ]
57+
{% endif %}

src/build.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,44 +57,55 @@ pub async fn build_with_output(
5757
ctx.insert("custom_init", init.trim());
5858
}
5959
}
60+
ctx.insert("web_client", &cfg.web_client);
61+
6062
let install_content = tmpl
6163
.render("install.sh", &ctx)
6264
.context("Failed to render installation script")?;
65+
6366
let entrypoint_content = tmpl
6467
.render("entrypoint.sh", &ctx)
6568
.context("Failed to render entrypoint script")?;
69+
6670
dbg!(&install_content);
71+
6772
let content = tmpl
6873
.render("dockerfile", &ctx)
6974
.context("Failed to render dockerfile")?;
75+
7076
let config_header = make_header("config.toml", config_content.len() as u64, 0o644)
7177
.context("Failed to create config header")?;
7278
tarball
7379
.append(&config_header, config_content.as_bytes())
7480
.await
7581
.context("Failed to archive config.toml")?;
82+
7683
let dockerfile_header = make_header("Dockerfile", content.len() as u64, 0o644)
7784
.context("Failed to create dockerfile header")?;
7885
tarball
7986
.append(&dockerfile_header, content.as_bytes())
8087
.await
8188
.context("Failed to append dockerfile to tarball")?;
89+
8290
let install_header = make_header("install.sh", install_content.len() as u64, 0o644)
8391
.context("Failed to create install header")?;
8492
tarball
8593
.append(&install_header, install_content.as_bytes())
8694
.await
8795
.context("Failed to append install.sh to tarball")?;
96+
8897
let entrypoint_header = make_header("entrypoint.sh", entrypoint_content.len() as u64, 0o644)
8998
.context("Failed to create entrypoint header")?;
9099
tarball
91100
.append(&entrypoint_header, entrypoint_content.as_bytes())
92101
.await
93102
.context("Failed to append entrypoint.sh to tar")?;
103+
94104
let out_data = tarball
95105
.into_inner()
96106
.await
97107
.context("Failed to finish tarball")?;
108+
98109
match output {
99110
Some(out_path) => {
100111
tokio::fs::write(out_path, out_data)

0 commit comments

Comments
 (0)