Skip to content

Commit c125a67

Browse files
AlexMikhalevjoepio
authored andcommitted
Example of Earthly, needs fixes for node build paths
Signed-off-by: AlexMikhalev <alex@metacortex.engineer>
1 parent 873caf3 commit c125a67

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

Earthfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
VERSION 0.7
2+
PROJECT applied-knowledge-systems/atomic-server
3+
# You can compile front end separately and copy dist folder
4+
# IMPORT ./browser AS browser
5+
FROM rust:latest
6+
WORKDIR /code
7+
8+
main-pipeline:
9+
PIPELINE --push
10+
TRIGGER push main
11+
TRIGGER pr main
12+
ARG tag=latest
13+
BUILD +build --tag=$tag
14+
15+
deps:
16+
RUN curl -fsSL https://bun.sh/install | bash
17+
RUN /root/.bun/bin/bun install -y pnpm
18+
# COPY . .
19+
COPY --dir server lib cli desktop Cargo.lock Cargo.toml .
20+
# RUN mkdir src
21+
# RUN touch src/main.rs # adding main.rs stub so cargo fetch works to prepare the cache
22+
RUN cargo fetch
23+
24+
test:
25+
FROM +deps
26+
RUN cargo test
27+
28+
build:
29+
FROM +deps
30+
RUN rustup target add x86_64-unknown-linux-musl
31+
RUN apt update && apt install -y musl-tools musl-dev
32+
RUN update-ca-certificates
33+
WORKDIR /app
34+
# FIXME: Joep you need to fix this line and modify Earthfile inside browser
35+
# COPY browser+build/dist ./public
36+
COPY --dir server lib cli desktop Cargo.lock Cargo.toml .
37+
RUN cargo build --release --bin atomic-server --config net.git-fetch-with-cli=true --target x86_64-unknown-linux-musl
38+
RUN strip -s /app/target/x86_64-unknown-linux-musl/release/atomic-server
39+
SAVE ARTIFACT /app/target/x86_64-unknown-linux-musl/release/atomic-server
40+
41+
docker:
42+
# We only need a small runtime for this step, but make sure glibc is installed
43+
FROM scratch
44+
COPY --chmod=0755 +build/atomic-server /atomic-server-bin
45+
# For a complete list of possible ENV vars or available flags, run with `--help`
46+
ENV ATOMIC_STORE_PATH="/atomic-storage/db"
47+
ENV ATOMIC_CONFIG_PATH="/atomic-storage/config.toml"
48+
ENV ATOMIC_PORT="80"
49+
EXPOSE 80
50+
VOLUME /atomic-storage
51+
ENTRYPOINT ["/atomic-server-bin"]
52+
SAVE IMAGE --push ghcr.io/applied-knowledge-systems/atomic-server:edge

browser/Earthfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
VERSION 0.7
2+
PROJECT applied-knowledge-systems/atomic-server
3+
FROM node:latest
4+
WORKDIR browser
5+
6+
main-pipeline:
7+
PIPELINE --push
8+
TRIGGER push main
9+
TRIGGER pr main
10+
ARG tag=latest
11+
BUILD +build --tag=$tag
12+
13+
deps:
14+
RUN curl -f https://get.pnpm.io/v6.14.js | node - add --global pnpm
15+
COPY . .
16+
RUN pnpm install --no-frozen-lockfile
17+
SAVE ARTIFACT node_modules /node_modules
18+
19+
build:
20+
FROM +deps
21+
RUN pnpm run build
22+
SAVE ARTIFACT dist /dist AS LOCAL dist

0 commit comments

Comments
 (0)