From 0d1c05857edb66376e12d2f794eda747ae655640 Mon Sep 17 00:00:00 2001 From: Nino Date: Mon, 19 Aug 2024 11:14:51 -0400 Subject: [PATCH 01/11] Create lua.alpine.Dockerfile --- g3proxy/docker/lua.alpine.Dockerfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 g3proxy/docker/lua.alpine.Dockerfile diff --git a/g3proxy/docker/lua.alpine.Dockerfile b/g3proxy/docker/lua.alpine.Dockerfile new file mode 100644 index 000000000..111cd0939 --- /dev/null +++ b/g3proxy/docker/lua.alpine.Dockerfile @@ -0,0 +1,15 @@ +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 +ENV PKG_CONFIG_PATH=/usr/lib/pkgconfig +RUN cargo build --profile release-lto \ + --no-default-features --features quic,c-ares,hickory,lua54 \ + -p g3proxy -p g3proxy-ctl + +FROM alpine:latest +RUN apk add --no-cache ca-certificates +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"] From c0fabe31270560f59fa48d1b10385e9ca92ee562 Mon Sep 17 00:00:00 2001 From: onin Date: Wed, 21 Aug 2024 01:10:16 +0200 Subject: [PATCH 02/11] a pretty neat lua alpine dockerfile --- g3proxy/docker/lua.alpine.Dockerfile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/g3proxy/docker/lua.alpine.Dockerfile b/g3proxy/docker/lua.alpine.Dockerfile index 111cd0939..71077fe42 100644 --- a/g3proxy/docker/lua.alpine.Dockerfile +++ b/g3proxy/docker/lua.alpine.Dockerfile @@ -1,3 +1,13 @@ +FROM nickblah/lua:5.4-luarocks-alpine AS lua +RUN apk add --no-cache build-base +# install lua modules here. +# this one is just an example. +# beware: lua's c modules (e.g. cjson), +# they need to be statically linked +# and won't work when installing like this. +# this is because alpine uses musl libc. +RUN luarocks install dkjson + FROM rust:alpine AS builder WORKDIR /usr/src/g3 COPY . . @@ -9,7 +19,14 @@ RUN cargo build --profile release-lto \ 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"] +CMD ["-Vvv"] \ No newline at end of file From 6a5b02bba495779b3e50d770bda2acf19376a9f4 Mon Sep 17 00:00:00 2001 From: onin Date: Wed, 21 Aug 2024 01:13:49 +0200 Subject: [PATCH 03/11] better comment wording in lua.alpine.Dockerfile --- g3proxy/docker/lua.alpine.Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/g3proxy/docker/lua.alpine.Dockerfile b/g3proxy/docker/lua.alpine.Dockerfile index 71077fe42..bd079b121 100644 --- a/g3proxy/docker/lua.alpine.Dockerfile +++ b/g3proxy/docker/lua.alpine.Dockerfile @@ -4,8 +4,8 @@ RUN apk add --no-cache build-base # this one is just an example. # beware: lua's c modules (e.g. cjson), # they need to be statically linked -# and won't work when installing like this. -# this is because alpine uses musl libc. +# and won't work when installing in +# alpine, because alpine uses musl libc. RUN luarocks install dkjson FROM rust:alpine AS builder From 86507b03ebfd604183386a5b77f8e3113d50e5b9 Mon Sep 17 00:00:00 2001 From: onin Date: Wed, 21 Aug 2024 01:15:49 +0200 Subject: [PATCH 04/11] better comment wording in lua.alpine.Dockerfile --- g3proxy/docker/lua.alpine.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/g3proxy/docker/lua.alpine.Dockerfile b/g3proxy/docker/lua.alpine.Dockerfile index bd079b121..3ecdf44e7 100644 --- a/g3proxy/docker/lua.alpine.Dockerfile +++ b/g3proxy/docker/lua.alpine.Dockerfile @@ -1,7 +1,7 @@ FROM nickblah/lua:5.4-luarocks-alpine AS lua RUN apk add --no-cache build-base # install lua modules here. -# this one is just an example. +# dkjson is just an example. # beware: lua's c modules (e.g. cjson), # they need to be statically linked # and won't work when installing in From d700e9f2153ec7ea96be5dc9614de0374e6ac849 Mon Sep 17 00:00:00 2001 From: Nino Date: Wed, 21 Aug 2024 04:34:40 +0200 Subject: [PATCH 05/11] Update lua.alpine.Dockerfile Better wording --- g3proxy/docker/lua.alpine.Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/g3proxy/docker/lua.alpine.Dockerfile b/g3proxy/docker/lua.alpine.Dockerfile index 3ecdf44e7..dd0e7b224 100644 --- a/g3proxy/docker/lua.alpine.Dockerfile +++ b/g3proxy/docker/lua.alpine.Dockerfile @@ -2,10 +2,10 @@ FROM nickblah/lua:5.4-luarocks-alpine AS lua RUN apk add --no-cache build-base # install lua modules here. # dkjson is just an example. -# beware: lua's c modules (e.g. cjson), -# they need to be statically linked +# beware: lua's c modules (e.g. cjson) +# need to be statically linked # and won't work when installing in -# alpine, because alpine uses musl libc. +# alpine via luarocks. RUN luarocks install dkjson FROM rust:alpine AS builder From cc1ffb89448399b544eee0f74de0d063a3030153 Mon Sep 17 00:00:00 2001 From: onin Date: Wed, 21 Aug 2024 21:48:05 +0200 Subject: [PATCH 06/11] Attempting to compile in g3proxy-lua but it doesn't work. --- g3proxy/docker/lua.alpine.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/g3proxy/docker/lua.alpine.Dockerfile b/g3proxy/docker/lua.alpine.Dockerfile index 3ecdf44e7..ca180fb56 100644 --- a/g3proxy/docker/lua.alpine.Dockerfile +++ b/g3proxy/docker/lua.alpine.Dockerfile @@ -15,7 +15,7 @@ RUN apk add --no-cache musl-dev cmake capnproto-dev openssl-dev openssl-libs-sta ENV PKG_CONFIG_PATH=/usr/lib/pkgconfig RUN cargo build --profile release-lto \ --no-default-features --features quic,c-ares,hickory,lua54 \ - -p g3proxy -p g3proxy-ctl + -p g3proxy -p g3proxy-ctl -p g3proxy-lua FROM alpine:latest RUN apk add --no-cache ca-certificates From 90e3a39187998d4b6178f12d78def48e8dad7e03 Mon Sep 17 00:00:00 2001 From: onin Date: Fri, 23 Aug 2024 22:06:22 +0200 Subject: [PATCH 07/11] Added the missing COPY g3proxy-lua --- g3proxy/docker/lua.alpine.Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/g3proxy/docker/lua.alpine.Dockerfile b/g3proxy/docker/lua.alpine.Dockerfile index 140822cdb..1d7002f16 100644 --- a/g3proxy/docker/lua.alpine.Dockerfile +++ b/g3proxy/docker/lua.alpine.Dockerfile @@ -28,5 +28,6 @@ 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-ctl /usr/bin/g3proxy-lua ENTRYPOINT ["/usr/bin/g3proxy"] CMD ["-Vvv"] \ No newline at end of file From 8538fd6b1f0380bf695c7431ce1e037e45a85be5 Mon Sep 17 00:00:00 2001 From: onin Date: Mon, 26 Aug 2024 01:04:49 +0200 Subject: [PATCH 08/11] openssl-libs-static and c-ares-static can be removed --- g3proxy/docker/lua.alpine.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/g3proxy/docker/lua.alpine.Dockerfile b/g3proxy/docker/lua.alpine.Dockerfile index 1d7002f16..dc570c091 100644 --- a/g3proxy/docker/lua.alpine.Dockerfile +++ b/g3proxy/docker/lua.alpine.Dockerfile @@ -11,7 +11,7 @@ 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 +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 RUN cargo build --profile release-lto \ --no-default-features --features quic,c-ares,hickory,lua54 \ From 9ead099399ded814f7789cc7f40a71acbeb87cf0 Mon Sep 17 00:00:00 2001 From: onin Date: Mon, 26 Aug 2024 01:05:04 +0200 Subject: [PATCH 09/11] fix - the src file is still g3proxy-ctl --- g3proxy/docker/lua.alpine.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/g3proxy/docker/lua.alpine.Dockerfile b/g3proxy/docker/lua.alpine.Dockerfile index dc570c091..90538f65e 100644 --- a/g3proxy/docker/lua.alpine.Dockerfile +++ b/g3proxy/docker/lua.alpine.Dockerfile @@ -28,6 +28,6 @@ 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-ctl /usr/bin/g3proxy-lua +COPY --from=builder /usr/src/g3/target/release-lto/g3proxy-lua /usr/bin/g3proxy-lua ENTRYPOINT ["/usr/bin/g3proxy"] CMD ["-Vvv"] \ No newline at end of file From c3759de4e1df93671cd3fc90d2517851caa98d68 Mon Sep 17 00:00:00 2001 From: onin Date: Mon, 26 Aug 2024 22:44:51 +0200 Subject: [PATCH 10/11] disable static linking for lua.alpine.Dockerfile (app crashes) --- g3proxy/docker/lua.alpine.Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/g3proxy/docker/lua.alpine.Dockerfile b/g3proxy/docker/lua.alpine.Dockerfile index 90538f65e..10806b0a6 100644 --- a/g3proxy/docker/lua.alpine.Dockerfile +++ b/g3proxy/docker/lua.alpine.Dockerfile @@ -13,6 +13,7 @@ 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 +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 736e36dfb3e0b36b86afd522d9611a392e70ed49 Mon Sep 17 00:00:00 2001 From: onin Date: Tue, 27 Aug 2024 21:18:42 +0200 Subject: [PATCH 11/11] missing dynamic libs --- g3proxy/docker/lua.alpine.Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/g3proxy/docker/lua.alpine.Dockerfile b/g3proxy/docker/lua.alpine.Dockerfile index 10806b0a6..140484345 100644 --- a/g3proxy/docker/lua.alpine.Dockerfile +++ b/g3proxy/docker/lua.alpine.Dockerfile @@ -19,7 +19,8 @@ RUN cargo build --profile release-lto \ -p g3proxy -p g3proxy-ctl -p g3proxy-lua FROM alpine:latest -RUN apk add --no-cache ca-certificates +# 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