-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(oci): add server-side container support
- Loading branch information
Showing
4 changed files
with
86 additions
and
21 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
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
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright (c) 2024 Ho Kim (ho.kim@ulagbulag.io). All rights reserved. | ||
# Use of this source code is governed by a GPL-3-style license that can be | ||
# found in the LICENSE file. | ||
|
||
# Configure environment variables | ||
ARG DEBIAN_VERSION="bookworm" | ||
ARG PACKAGE="cassette-server" | ||
|
||
# Be ready for serving | ||
FROM docker.io/library/debian:${DEBIAN_VERSION} as server | ||
|
||
# Server Configuration | ||
EXPOSE 6080/tcp | ||
WORKDIR /usr/local/bin | ||
CMD [ "/bin/sh" ] | ||
|
||
# Be ready for building | ||
FROM docker.io/library/rust:1-${DEBIAN_VERSION} as builder | ||
|
||
# Load source files | ||
ADD . /src | ||
WORKDIR /src | ||
|
||
# Build it! | ||
RUN \ | ||
# Cache build outputs | ||
--mount=type=cache,target=/src/target \ | ||
--mount=type=cache,target=/usr/local/cargo/registry \ | ||
true \ | ||
# Exclude non-server packages | ||
&& find ./ -type f -name Cargo.toml -exec sed -i 's/^\( *\)\(.*\# *exclude *( *server *)\)$/\1# \2/g' {} + \ | ||
&& find ./ -type f -name Cargo.toml -exec sed -i 's/^\( *\)\# *\(.*\# *include *( *server *)\)$/\1\2/g' {} + \ | ||
# Include target-dependent packages | ||
&& find ./ -type f -name Cargo.toml -exec sed -i 's/^\( *\)\(.*\# *include *( *[_0-9a-z-]\+ *)\)$/\1# \2/g' {} + \ | ||
&& find ./ -type f -name Cargo.toml -exec sed -i "s/^\( *\)\# *\(.*\# *include *( *$(uname -m) *)\)$/\1\2/g" {} + \ | ||
# Build | ||
&& cargo build --all --workspace --release \ | ||
&& find ./target/release/ -maxdepth 1 -type f -perm -a=x -print0 | xargs -0 -I {} mv {} /out \ | ||
&& cp ./Trunk.toml /out \ | ||
&& mv ./LICENSE /LICENSE | ||
|
||
# Copy executable files | ||
FROM server | ||
ARG PACKAGE | ||
COPY --from=builder /out/* /usr/local/bin/ | ||
COPY --from=builder /LICENSE /usr/share/licenses/${PACKAGE}/LICENSE |
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