Skip to content

Commit

Permalink
Example of Earthly, needs fixes for node build paths
Browse files Browse the repository at this point in the history
Signed-off-by: AlexMikhalev <[email protected]>
  • Loading branch information
AlexMikhalev committed Oct 2, 2023
1 parent 3675c12 commit 7915ba6
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
VERSION 0.7
PROJECT applied-knowledge-systems/atomic-server
# You can compile front end separately and copy dist folder
# IMPORT ./browser AS browser
FROM rust:latest
WORKDIR /code

main-pipeline:
PIPELINE --push
TRIGGER push main
TRIGGER pr main
ARG tag=latest
BUILD +build --tag=$tag

deps:
RUN curl -fsSL https://bun.sh/install | bash
RUN /root/.bun/bin/bun install -y pnpm
# COPY . .
COPY --dir server lib cli desktop Cargo.lock Cargo.toml .
# RUN mkdir src
# RUN touch src/main.rs # adding main.rs stub so cargo fetch works to prepare the cache
RUN cargo fetch

test:
FROM +deps
RUN cargo test

build:
FROM +deps
RUN rustup target add x86_64-unknown-linux-musl
RUN apt update && apt install -y musl-tools musl-dev
RUN update-ca-certificates
WORKDIR /app
# FIXME: Joep you need to fix this line and modify Earthfile inside browser
# COPY browser+build/dist ./public
COPY --dir server lib cli desktop Cargo.lock Cargo.toml .
RUN cargo build --release --bin atomic-server --config net.git-fetch-with-cli=true --target x86_64-unknown-linux-musl
RUN strip -s /app/target/x86_64-unknown-linux-musl/release/atomic-server
SAVE ARTIFACT /app/target/x86_64-unknown-linux-musl/release/atomic-server

docker:
# We only need a small runtime for this step, but make sure glibc is installed
FROM scratch
COPY --chmod=0755 +build/atomic-server /atomic-server-bin
# For a complete list of possible ENV vars or available flags, run with `--help`
ENV ATOMIC_STORE_PATH="/atomic-storage/db"
ENV ATOMIC_CONFIG_PATH="/atomic-storage/config.toml"
ENV ATOMIC_PORT="80"
EXPOSE 80
VOLUME /atomic-storage
ENTRYPOINT ["/atomic-server-bin"]
SAVE IMAGE --push ghcr.io/applied-knowledge-systems/atomic-server:edge
22 changes: 22 additions & 0 deletions browser/Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
VERSION 0.7
PROJECT applied-knowledge-systems/atomic-server
FROM node:latest
WORKDIR browser

main-pipeline:
PIPELINE --push
TRIGGER push main
TRIGGER pr main
ARG tag=latest
BUILD +build --tag=$tag

deps:
RUN curl -f https://get.pnpm.io/v6.14.js | node - add --global pnpm
COPY . .
RUN pnpm install --no-frozen-lockfile
SAVE ARTIFACT node_modules /node_modules

build:
FROM +deps
RUN pnpm run build
SAVE ARTIFACT dist /dist AS LOCAL dist

0 comments on commit 7915ba6

Please sign in to comment.