Skip to content

Commit

Permalink
chore: update to alpine 3.20
Browse files Browse the repository at this point in the history
  • Loading branch information
strophy committed Jun 9, 2024
1 parent 73e354b commit 26ee2dd
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 63 deletions.
102 changes: 48 additions & 54 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1.4
# syntax=docker/dockerfile:1

ARG ALPINE_IMAGE_VERSION
ARG DART_IMAGE_VERSION
Expand Down Expand Up @@ -191,12 +191,18 @@ RUN xx-verify /out/usr/bin/protoc-gen-jsonschema

FROM alpine:${ALPINE_IMAGE_VERSION} as grpc_web
RUN apk add --no-cache \
autoconf \
automake \
build-base \
curl \
protobuf-dev
RUN mkdir -p /grpc-web
git \
libtool
ARG GRPC_WEB_VERSION
RUN curl -sSL https://api.github.com/repos/grpc/grpc-web/tarball/${GRPC_WEB_VERSION} | tar xz --strip 1 -C /grpc-web
RUN git clone --recurse-submodules --branch=$GRPC_WEB_VERSION https://github.com/grpc/grpc-web.git
WORKDIR /grpc-web/third_party/protobuf
RUN ./autogen.sh && \
./configure && \
make -j$(nproc) && \
make install
WORKDIR /grpc-web
RUN make -j$(nproc) install-plugin
RUN install -Ds /usr/local/bin/protoc-gen-grpc-web /out/usr/bin/protoc-gen-grpc-web
Expand Down Expand Up @@ -256,12 +262,6 @@ RUN apt-get install -y \
ARG TARGETOS TARGETARCH GRPC_SWIFT_VERSION
RUN <<EOF
mkdir -p /protoc-gen-swift
# Skip arm64 build due to https://forums.swift.org/t/build-crash-when-building-in-qemu-using-new-swift-5-6-arm64-image/56090/
# TODO: Remove this conditional once fixed
if [ "${TARGETARCH}" = "arm64" ]; then
echo "Skipping arm64 build due to error in Swift toolchain"
exit 0
fi
case ${TARGETARCH} in
"amd64") SWIFT_LIB_DIR=/lib64 && SWIFT_LINKER=ld-${TARGETOS}-x86-64.so.2 ;;
"arm64") SWIFT_LIB_DIR=/lib && SWIFT_LINKER=ld-${TARGETOS}-aarch64.so.1 ;;
Expand Down Expand Up @@ -330,7 +330,7 @@ RUN apk add --no-cache \

ARG TARGETARCH
ARG PROTOC_GEN_JS_VERSION
ARG BAZEL_VERSION=6.1.0
ARG CPPFLAGS=-std=c++17
RUN <<EOF
# Skip arm64 build due to https://github.com/bazelbuild/bazel/issues/17220
# TODO: Remove this conditional once fixed
Expand All @@ -345,38 +345,35 @@ RUN <<EOF
mkdir -p /protoc_gen_js
cd /protoc_gen_js
curl -sSL https://api.github.com/repos/protocolbuffers/protobuf-javascript/tarball/${PROTOC_GEN_JS_VERSION} | tar xz --strip 1 -C /protoc_gen_js
bazel build plugin_files
bazel build --verbose_failures plugin_files
install -D /protoc_gen_js/bazel-bin/generator/protoc-gen-js /out/usr/bin/protoc-gen-js
xx-verify /out/usr/bin/protoc-gen-js
EOF


FROM node:${NODE_IMAGE_VERSION} as protoc_gen_ts
ARG NODE_IMAGE_VERSION
ARG PROTOC_GEN_TS_VERSION
RUN npm install -g pkg ts-protoc-gen@${PROTOC_GEN_TS_VERSION}
RUN pkg \
--compress Brotli \
--targets node${NODE_IMAGE_VERSION%%.*}-alpine \
-o protoc-gen-ts \
/usr/local/lib/node_modules/ts-protoc-gen
RUN install -D protoc-gen-ts /out/usr/bin/protoc-gen-ts

FROM sbtscala/scala-sbt:${SCALA_SBT_IMAGE_VERSION} as protoc_gen_scala
RUN mkdir -p /scala-protobuf
ARG PROTOC_GEN_SCALA_VERSION
RUN curl -sSL https://api.github.com/repos/scalapb/ScalaPB/tarball/${PROTOC_GEN_SCALA_VERSION} | tar xz --strip 1 -C /scala-protobuf
WORKDIR /scala-protobuf
RUN gu install native-image
# Make sbt use the version of native-image installed by gu instead of downloading a separate version
ARG NATIVE_IMAGE_INSTALLED=true
RUN ./make_reflect_config.sh
RUN sbt protocGenScalaNativeImage/nativeImage
RUN install -D /scala-protobuf/target/protoc-gen-scala /out/usr/bin/protoc-gen-scala
ARG TARGETARCH
ARG PROTOC_GEN_SCALA_VERSION
ARG NATIVE_IMAGE_INSTALLED=true
ARG JAVA_OPTS="-Djdk.lang.Process.launchMechanism=vfork"
# Skip arm64 build due to https://github.com/spring-projects/spring-boot/issues/33429
RUN <<EOF
mkdir -p /scala-protobuf
mkdir -p /out
if [ "${TARGETARCH}" = "arm64" ]; then
echo "Skipping arm64 build due to error in Native Image toolchain"
exit 0
fi
curl -sSL https://api.github.com/repos/scalapb/ScalaPB/tarball/${PROTOC_GEN_SCALA_VERSION} | tar xz --strip 1 -C /scala-protobuf
cd /scala-protobuf
gu install native-image
./make_reflect_config.sh
sbt protocGenScalaNativeImage/nativeImage
install -D /scala-protobuf/target/protoc-gen-scala /out/usr/bin/protoc-gen-scala
EOF


FROM dart:${DART_IMAGE_VERSION} as protoc_gen_dart
RUN apt-get update
RUN apt-get install -y curl
RUN mkdir -p /dart-protobuf
ARG PROTOC_GEN_DART_VERSION
RUN curl -sSL https://api.github.com/repos/google/protobuf.dart/tarball/protoc_plugin-${PROTOC_GEN_DART_VERSION} | tar xz --strip 1 -C /dart-protobuf
Expand Down Expand Up @@ -413,31 +410,32 @@ COPY --from=protoc_gen_lint /out/ /out/
COPY --from=protoc_gen_rust /out/ /out/
COPY --from=protoc_gen_scala /out/ /out/
COPY --from=protoc_gen_validate /out/ /out/
ARG TARGETARCH
RUN find /out/usr/bin/ -type f \
-name 'protoc-gen-*' | \
xargs -P $(nproc) -I{} \
upx --lzma {}
RUN find /out -name "*.a" -delete -or -name "*.la" -delete


FROM alpine:${ALPINE_IMAGE_VERSION}
FROM node:${NODE_IMAGE_VERSION}
LABEL org.opencontainers.image.authors="Romāns Volosatovs <rvolosatovs@riseup.net>, Leon White <badfunkstripe@gmail.com>"
ARG PROTOC_GEN_NANOPB_VERSION
ARG PROTOC_GEN_NANOPB_VERSION PROTOC_GEN_TS_VERSION
RUN apk add --no-cache \
bash \
grpc \
grpc-java \
# Disabled due to https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/46676
# grpc-java \
grpc-plugins \
protobuf \
protobuf-dev \
protobuf-c-compiler \
python3
COPY --from=upx /out/ /
COPY --from=protoc_gen_ts /out/ /
COPY --from=protoc_gen_dart /out/ /
COPY --from=protoc_gen_dart /runtime/ /
RUN python3 -m ensurepip && pip3 install --no-cache nanopb==${PROTOC_GEN_NANOPB_VERSION}
RUN npm install -g ts-protoc-gen@${PROTOC_GEN_TS_VERSION}
RUN rm /usr/lib/python3.12/EXTERNALLY-MANAGED && \
python3 -m ensurepip && pip3 install --no-cache setuptools nanopb==${PROTOC_GEN_NANOPB_VERSION}
RUN ln -s /usr/bin/grpc_cpp_plugin /usr/bin/protoc-gen-grpc-cpp && \
ln -s /usr/bin/grpc_csharp_plugin /usr/bin/protoc-gen-grpc-csharp && \
ln -s /usr/bin/grpc_node_plugin /usr/bin/protoc-gen-grpc-js && \
Expand All @@ -446,7 +444,9 @@ RUN ln -s /usr/bin/grpc_cpp_plugin /usr/bin/protoc-gen-grpc-cpp && \
ln -s /usr/bin/grpc_python_plugin /usr/bin/protoc-gen-grpc-python && \
ln -s /usr/bin/grpc_ruby_plugin /usr/bin/protoc-gen-grpc-ruby && \
ln -s /usr/bin/protoc-gen-go-grpc /usr/bin/protoc-gen-grpc-go && \
ln -s /usr/bin/protoc-gen-rust-grpc /usr/bin/protoc-gen-grpc-rust
ln -s /usr/bin/protoc-gen-rust-grpc /usr/bin/protoc-gen-grpc-rust && \
ln -s /protoc-gen-swift/protoc-gen-grpc-swift /usr/bin/protoc-gen-grpc-swift && \
ln -s /protoc-gen-swift/protoc-gen-swift /usr/bin/protoc-gen-swift
COPY protoc-wrapper /usr/bin/protoc-wrapper
RUN mkdir -p /test && \
protoc-wrapper \
Expand All @@ -460,13 +460,14 @@ RUN mkdir -p /test && \
--grpc-cpp_out=/test \
--grpc-csharp_out=/test \
--grpc-go_out=/test \
--grpc-java_out=/test \
# --grpc-java_out=/test \
--grpc-js_out=/test \
--grpc-objc_out=/test \
--grpc-php_out=/test \
--grpc-python_out=/test \
--grpc-ruby_out=/test \
--grpc-rust_out=/test \
--grpc-swift_out=/test \
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:/test \
--java_out=/test \
--jsonschema_out=/test \
Expand All @@ -475,27 +476,20 @@ RUN mkdir -p /test && \
--php_out=/test \
--python_out=/test \
--ruby_out=/test \
--rust_out=/test \
--scala_out=/test \
--rust_out=experimental-codegen=enabled,kernel=cpp:/test \
--swift_out=/test \
--ts_out=/test \
--validate_out=lang=go:/test \
google/protobuf/any.proto
RUN protoc-wrapper \
--gogo_out=/test \
google/protobuf/any.proto
ARG TARGETARCH
RUN <<EOF
if ! [ "${TARGETARCH}" = "arm64" ]; then
ln -s /protoc-gen-swift/protoc-gen-grpc-swift /usr/bin/protoc-gen-grpc-swift
ln -s /protoc-gen-swift/protoc-gen-swift /usr/bin/protoc-gen-swift
fi
EOF
RUN <<EOF
if ! [ "${TARGETARCH}" = "arm64" ]; then
protoc-wrapper \
--grpc-swift_out=/test \
--js_out=import_style=commonjs:/test \
--swift_out=/test \
--scala_out=/test \
google/protobuf/any.proto
fi
EOF
Expand Down
18 changes: 9 additions & 9 deletions deps.list
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
ALPINE_IMAGE_VERSION=3.18
DART_IMAGE_VERSION=3.4.2
GO_IMAGE_VERSION=1.21.4-alpine3.18
ALPINE_IMAGE_VERSION=3.20
DART_IMAGE_VERSION=3.4.3
GO_IMAGE_VERSION=1.22.4-alpine3.20
GOOGLE_API_VERSION=716a2814e199eeef8fd9f3e11418ee0881ac833a
GRPC_GATEWAY_VERSION=v2.20.0
GRPC_RUST_VERSION=v0.8.3
GRPC_SWIFT_VERSION=1.21.0
GRPC_WEB_VERSION=1.5.0
NODE_IMAGE_VERSION=18.18.2-alpine3.18
NODE_IMAGE_VERSION=22.2.0-alpine3.20
PROTOC_GEN_DART_VERSION=v21.1.2
PROTOC_GEN_DOC_VERSION=v1.5.1
PROTOC_GEN_GO_GRPC_VERSION=v1.64.0
Expand All @@ -15,17 +15,17 @@ PROTOC_GEN_GOGO_VERSION=v1.3.2
PROTOC_GEN_GORM_VERSION=v1.1.4
PROTOC_GEN_GOTEMPLATE_VERSION=v1.11.3
PROTOC_GEN_GOVALIDATORS_VERSION=v0.3.2
PROTOC_GEN_GQL_VERSION=v0.8.0
PROTOC_GEN_GQL_VERSION=v0.10.0
PROTOC_GEN_JS_VERSION=v3.21.2
PROTOC_GEN_JSONSCHEMA_VERSION=1.4.1
PROTOC_GEN_LINT_VERSION=v0.3.0
PROTOC_GEN_NANOPB_VERSION=0.4.8
PROTOC_GEN_RUST_VERSION=v3.4.0
PROTOC_GEN_SCALA_VERSION=v0.11.16
PROTOC_GEN_SCALA_VERSION=v0.11.17
PROTOC_GEN_TS_VERSION=0.15.0
PROTOC_GEN_VALIDATE_VERSION=v1.0.4
RUST_IMAGE_VERSION=1.78.0-alpine3.18
SCALA_SBT_IMAGE_VERSION=graalvm-ce-22.3.3-b1-java17_1.9.9_2.12.19
SWIFT_IMAGE_VERSION=5.10-focal
RUST_IMAGE_VERSION=1.78.0-alpine3.20
SCALA_SBT_IMAGE_VERSION=graalvm-ce-22.3.3-b1-java17_1.9.9_2.12.18
SWIFT_IMAGE_VERSION=5.10.1-jammy
UPX_VERSION=4.2.4
XX_IMAGE_VERSION=1.4.0

0 comments on commit 26ee2dd

Please sign in to comment.