mirror of
https://github.com/sergi0g/cup.git
synced 2025-11-18 09:53:43 -05:00
Optimize workflows (#25)
feat: optimize workflows --------- Co-authored-by: Stavros <steveiliop56@gmail.com>
This commit is contained in:
40
Dockerfile
40
Dockerfile
@@ -1,20 +1,42 @@
|
||||
FROM rust:alpine AS build
|
||||
WORKDIR /
|
||||
### Build UI ###
|
||||
FROM node:20 AS web
|
||||
|
||||
# Install bun
|
||||
RUN curl -fsSL https://bun.sh/install | bash
|
||||
|
||||
# Copy web folder
|
||||
COPY ./web /web
|
||||
WORKDIR /web
|
||||
|
||||
# Install requirements
|
||||
RUN ~/.bun/bin/bun install
|
||||
|
||||
# Build frontend
|
||||
RUN ~/.bun/bin/bun run build
|
||||
|
||||
### Build Cup ###
|
||||
FROM rust:1.80.1-alpine AS build
|
||||
|
||||
# Requirements
|
||||
RUN apk add musl-dev
|
||||
|
||||
RUN USER=root cargo new --bin cup
|
||||
# Copy files
|
||||
WORKDIR /cup
|
||||
|
||||
COPY Cargo.toml Cargo.lock .
|
||||
RUN cargo build --release
|
||||
RUN rm -rf src/
|
||||
COPY Cargo.toml .
|
||||
COPY Cargo.lock .
|
||||
COPY ./src ./src
|
||||
|
||||
COPY src src
|
||||
# This is a very bad workaround, but cargo only triggers a rebuild this way for some reason
|
||||
RUN printf "\n" >> src/main.rs
|
||||
# Copy UI from web builder
|
||||
COPY --from=web /web/dist src/static
|
||||
|
||||
# Build
|
||||
RUN cargo build --release
|
||||
|
||||
### Main ###
|
||||
FROM scratch
|
||||
|
||||
# Copy binary
|
||||
COPY --from=build /cup/target/release/cup /cup
|
||||
|
||||
ENTRYPOINT ["/cup"]
|
||||
Reference in New Issue
Block a user