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 7 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
32 changes: 32 additions & 0 deletions g3proxy/docker/lua.alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 openssl-libs-static c-ares-dev c-ares-static lua5.4-dev pkgconfig
zh-jq-b marked this conversation as resolved.
Show resolved Hide resolved
ENV PKG_CONFIG_PATH=/usr/lib/pkgconfig
NinoSkopac marked this conversation as resolved.
Show resolved Hide resolved
RUN cargo build --profile release-lto \
--no-default-features --features quic,c-ares,hickory,lua54 \
-p g3proxy -p g3proxy-ctl
Copy link
Member

Choose a reason for hiding this comment

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

You may also want to compile in g3proxy-lua, which can be used to verify the call result of the script

Copy link
Contributor Author

@NinoSkopac NinoSkopac Aug 21, 2024

Choose a reason for hiding this comment

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

Append -p g3proxy-lua to line 18?

Copy link
Member

Choose a reason for hiding this comment

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

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay you got it, I'll add that tonight after testing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the bit of code but it doesn't work.

Inside the container, after rebuilding and running:

ls /usr/bin/g3proxy
g3proxy      g3proxy-ctl

There's no g3proxy-lua binary.

Copy link
Member

Choose a reason for hiding this comment

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

COPY is also needed in the final build step.


FROM alpine:latest
RUN apk add --no-cache ca-certificates
# 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
ENTRYPOINT ["/usr/bin/g3proxy"]
CMD ["-Vvv"]