Skip to content

Commit 7147f5e

Browse files
authored
#285 AMD64 Static Binary and Docker Image (#493)
* setup static binary for linux amd64 * generating release on pullrequest * [Gradle Release Plugin] - new version commit: '3.20.1-snapshot'. * release notes * [Gradle Release Plugin] - new version commit: '3.21.0-snapshot'. * setup docker image * fixing path * adjusting amd64 static building * adjusting amd64 static building * adjusting amd64 static building * adjusting amd64 static building * adjusting amd64 static building * upgrading running docker images * create tmp dir when it not exists * upgrading docker image * release notes * [Gradle Release Plugin] - new version commit: '3.21.1-snapshot'. * reverting feature * release notes * release notes * release notes * adjusting ci cd
1 parent 099b1c4 commit 7147f5e

File tree

11 files changed

+131
-5
lines changed

11 files changed

+131
-5
lines changed

.github/workflows/actions-deploy.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- master
77

8+
89
permissions:
910
contents: write
1011

@@ -66,6 +67,44 @@ jobs:
6667
files: |
6768
./build/compressed-artifacts/*
6869
70+
linux_amd64_static_release:
71+
runs-on: ubuntu-latest
72+
needs: primary_release
73+
env:
74+
APP_VERSION: ${{ needs.primary_release.outputs.APP_VERSION }}
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v3
78+
79+
- name: Check app version
80+
run: echo "$APP_VERSION"
81+
82+
- uses: actions/download-artifact@v3
83+
with:
84+
name: native-image-source
85+
path: ./build/artifacts/native-image-source/
86+
87+
- name: Linux Amd64 static Release
88+
run: |
89+
echo "app version=$APP_VERSION" &&\
90+
tree -h ./build/ &&\
91+
docker-compose -f docker-compose-deploy.yml run deploy bash -c '
92+
/bin/builder.bash deploy-amd64-static &&\
93+
echo "> Copying files to the host" &&\
94+
cp -rv /app/build/compressed-artifacts /host/build/ &&\
95+
echo "Linux amd64 static is done!"
96+
' &&\
97+
tree -h ./build/
98+
# Release details will be provided by primary-release
99+
- name: Github release
100+
uses: softprops/action-gh-release@v1
101+
with:
102+
tag_name: ${{ env.APP_VERSION }}
103+
append_body: true
104+
body: ''
105+
files: |
106+
./build/compressed-artifacts/*
107+
69108
linux_arm_release:
70109
runs-on: ubuntu-latest
71110
needs: primary_release

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM debian:10-slim
1+
FROM debian:12-slim
22
COPY ./build/artifacts/linux-amd64/dns-proxy-server /app/dns-proxy-server
33
WORKDIR /app
44
LABEL dps.container=true

Dockerfile.aarch64

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM arm64v8/debian:10-slim
1+
FROM arm64v8/debian:12-slim
22
COPY ./build/artifacts/linux-aarch64/dns-proxy-server /app/dns-proxy-server
33
WORKDIR /app
44
LABEL dps.container=true

Dockerfile.amd64-static

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM scratch
2+
COPY ./build/artifacts/linux-amd64-static/dns-proxy-server /app/dns-proxy-server
3+
WORKDIR /app
4+
LABEL dps.container=true
5+
ENV DPS_CONTAINER=1
6+
VOLUME ["/var/run/docker.sock", "/var/run/docker.sock"]
7+
ENTRYPOINT ["/app/dns-proxy-server"]
8+
CMD ["-D", "java.io.tmpdir=/app"]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM debian:11
2+
3+
RUN apt-get update -y &&\
4+
apt-get install --force-yes -y build-essential libz-dev zlib1g-dev curl
5+
6+
ARG RESULT_LIB="/musl"
7+
8+
RUN mkdir ${RESULT_LIB} && \
9+
curl -L -o musl.tar.gz https://more.musl.cc/10.2.1/x86_64-linux-musl/x86_64-linux-musl-native.tgz && \
10+
tar -xvzf musl.tar.gz -C musl --strip-components 1 && \
11+
cp /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a ${RESULT_LIB}/lib/
12+
13+
ENV CC=/musl/bin/gcc
14+
15+
RUN curl -L -o zlib.tar.gz https://www.zlib.net/fossils/zlib-1.2.11.tar.gz && \
16+
mkdir zlib && tar -xvzf zlib.tar.gz -C zlib --strip-components 1 && \
17+
cd zlib && ./configure --static --prefix=/musl && \
18+
make && make install && \
19+
cd / && rm -rf /zlib && rm -f /zlib.tar.gz
20+
21+
ENV PATH="$PATH:/musl/bin"
22+
ENV GRAALVM_URL='https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz'
23+
24+
RUN mkdir /graalvm &&\
25+
curl -L $GRAALVM_URL > /tmp/graalvm.tgz &&\
26+
tar --strip 1 -zxvf /tmp/graalvm.tgz -C /graalvm &&\
27+
rm -r /tmp/* || true
28+
29+
ENV JAVA_HOME=/graalvm
30+
ENV PATH="${PATH}:$JAVA_HOME/bin"
31+
RUN uname -a && whoami && $JAVA_HOME/bin/java -version
32+
33+
WORKDIR /app/build
34+
COPY ./build/artifacts/native-image-source/ /app/build
35+
36+
RUN ls -lha &&\
37+
native-image --static --libc=musl -jar dns-proxy-server.jar dns-proxy-server
38+
39+
RUN ls -lhS &&\
40+
mkdir -p ./artifacts/linux-amd64-static &&\
41+
mv ./dns-proxy-server ./artifacts/linux-amd64-static/
42+
43+
ENTRYPOINT cat

RELEASE-NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.21.1
2+
* #435: Upgrading docker run images due glibc
3+
* #285: Linux AMD64 static binary
4+
15
## 3.20.0
26
* #435: GraalVM Upgrade to 21 LTS
37

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ graalvmNative {
122122
verbose = true
123123
fallback = false
124124
buildArgs.add('-J-Xmx5G')
125+
125126
}
126127
}
127128
}

builder.bash

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,19 @@ case $1 in
112112
;;
113113

114114
docker-push-arm )
115-
echo "> Push docker images to docker hub"
115+
echo "> Push docker arm image to docker hub"
116116
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin &&\
117117
docker-compose push image-linux-aarch64
118118
echo "Push done"
119119
;;
120120

121+
docker-push-amd64-static )
122+
echo "> Push docker amd64 static image to docker hub"
123+
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin &&\
124+
docker-compose push image-linux-amd64-static
125+
echo "Push done"
126+
;;
127+
121128
deploy )
122129

123130
echo "> Deploy started , current branch=$CURRENT_BRANCH"
@@ -136,6 +143,18 @@ case $1 in
136143
echo "> deploy done"
137144
;;
138145

146+
deploy-amd64-static )
147+
148+
echo "> Amd64 static deploy started , current branch=$CURRENT_BRANCH"
149+
ls -lhS build/*
150+
151+
./builder.bash build-backend amd64-static
152+
./builder.bash compress-artifacts
153+
./builder.bash docker-push-amd64-static
154+
155+
echo "> Amd64 Static deploy done"
156+
;;
157+
139158
deploy-arm )
140159

141160
echo "> Arm deploy started , current branch=$CURRENT_BRANCH"

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ services:
1414
context: .
1515
dockerfile: Dockerfile.builder.linux-amd64
1616

17+
build-linux-amd64-static:
18+
image: defreitas/dns-proxy-server-build:${VERSION:-snapshot}-amd64-static
19+
build:
20+
context: .
21+
dockerfile: Dockerfile.builder.linux-amd64-static
22+
1723
build-linux-aarch64:
1824
image: defreitas/dns-proxy-server-build:${VERSION:-snapshot}-aarch64
1925
build:
@@ -30,6 +36,12 @@ services:
3036
context: .
3137
dockerfile: Dockerfile
3238

39+
image-linux-amd64-static:
40+
image: defreitas/dns-proxy-server:${VERSION:-snapshot}-amd64-static
41+
build:
42+
context: .
43+
dockerfile: Dockerfile.amd64-static
44+
3345
image-linux-aarch64:
3446
image: defreitas/dns-proxy-server:${VERSION:-snapshot}-aarch64
3547
build:

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=3.20.0-snapshot
1+
version=3.21.1-snapshot

0 commit comments

Comments
 (0)