-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update dockerfile for new build stuff
- Loading branch information
Showing
1 changed file
with
15 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,38 @@ | ||
FROM rust:1 as builder | ||
FROM rust:1-alpine as builder | ||
|
||
# create empty projects | ||
RUN cargo new --bin go2 | ||
WORKDIR /go2 | ||
|
||
# copy package manifest in | ||
COPY Cargo.toml Cargo.lock /go2 | ||
COPY Cargo.toml Cargo.lock /go2/ | ||
|
||
|
||
RUN apk add --no-cache musl-dev | ||
# build to cache deps | ||
RUN cargo build --release | ||
RUN rm src/*.rs | ||
|
||
# copy source code (and sqlx stuff) (and templates) in | ||
# install tailwind cli | ||
# from https://github.com/Angatar/tailwindcss/blob/main/Dockerfile | ||
RUN apk add --no-cache wget jq | ||
ARG TARGETPLATFORM | ||
RUN wget -O tailwindcss https://github.com/tailwindlabs/tailwindcss/releases/download/$(wget -q -O - https://api.github.com/repos/tailwindlabs/tailwindcss/releases/latest | jq -r ".tag_name")/tailwindcss-$(echo $TARGETPLATFORM|sed 's/linux\//linux-/'|sed 's/arm\/v[-,7,6]/armv7/'|sed 's/amd64/x64/') \ | ||
&& chmod u+x tailwindcss | ||
|
||
# copy source code (and sqlx stuff) (and templates) (and static (css is build by cargo)) in | ||
COPY ./src ./src | ||
COPY ./.sqlx ./.sqlx | ||
COPY ./migrations ./migrations | ||
COPY ./templates ./templates | ||
COPY ./static ./static | ||
|
||
# build our code | ||
RUN rm ./target/release/deps/go2* | ||
RUN cargo build --release | ||
|
||
# new base, slimmer, no toolchains | ||
FROM debian:bullseye-slim | ||
FROM scratch | ||
COPY --from=builder /go2/target/release/go2 . | ||
COPY ./static ./static | ||
|
||
# static folder is built into binary | ||
|
||
CMD [ "./go2" ] |