Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpine Dockerfile with Lua #292

Merged
merged 16 commits into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions g3proxy/docker/lua.alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM nickblah/lua:5.4-luarocks-alpine AS lua
zh-jq-b marked this conversation as resolved.
Show resolved Hide resolved
RUN apk add --no-cache build-base
# install lua modules here.
# dkjson is just an example.
# beware: lua's c modules (e.g. cjson)
# need to be statically linked
# and won't work when installing in
# alpine via luarocks.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is no longer valid. fixing.

RUN luarocks install dkjson

FROM rust:alpine AS builder
WORKDIR /usr/src/g3
COPY . .
RUN apk add --no-cache musl-dev cmake capnproto-dev openssl-dev c-ares-dev lua5.4-dev pkgconfig
ENV PKG_CONFIG_PATH=/usr/lib/pkgconfig
NinoSkopac marked this conversation as resolved.
Show resolved Hide resolved
ENV RUSTFLAGS="-Ctarget-feature=-crt-static"
RUN cargo build --profile release-lto \
--no-default-features --features quic,c-ares,hickory,lua54 \
-p g3proxy -p g3proxy-ctl -p g3proxy-lua

FROM alpine:latest
# install dynamic libs
RUN apk add --no-cache ca-certificates libgcc c-ares lua5.4-libs
# Copy Lua binaries and modules from the lua stage
COPY --from=lua /usr/local/bin/lua /usr/local/bin/lua
COPY --from=lua /usr/local/bin/luarocks /usr/local/bin/luarocks
COPY --from=lua /usr/local/lib/lua /usr/local/lib/lua
COPY --from=lua /usr/local/share/lua /usr/local/share/lua
COPY --from=lua /usr/local/lib/luarocks /usr/local/lib/luarocks
# Copy the compiled binaries from the builder stage
COPY --from=builder /usr/src/g3/target/release-lto/g3proxy /usr/bin/g3proxy
COPY --from=builder /usr/src/g3/target/release-lto/g3proxy-ctl /usr/bin/g3proxy-ctl
COPY --from=builder /usr/src/g3/target/release-lto/g3proxy-lua /usr/bin/g3proxy-lua
ENTRYPOINT ["/usr/bin/g3proxy"]
CMD ["-Vvv"]
Loading