Skip to content

Commit 21076d7

Browse files
committed
Make default port 18888; build containers for alpine and ubuntu
1 parent bc42f2d commit 21076d7

9 files changed

+57
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
dependency-reduced-pom.xml
22
.idea
33
target
4+
?

Dockerfile.alpine

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM alpine:3.16.0
2+
3+
RUN wget https://download.bell-sw.com/vm/22.1.0/bellsoft-liberica-vm-openjdk17.0.3.1+2-22.1.0+2-linux-x64-musl.apk
4+
RUN wget -P /etc/apk/keys/ https://apk.bell-sw.com/[email protected]
5+
RUN apk add bellsoft-liberica-vm-openjdk17.0.3.1+2-22.1.0+2-linux-x64-musl.apk
6+
RUN rm bellsoft-liberica-vm-openjdk17.0.3.1+2-22.1.0+2-linux-x64-musl.apk
7+
8+
RUN apk add maven git alpine-sdk zlib-dev
9+
10+
RUN echo "" >> /etc/profile
11+
RUN echo "export JAVA_HOME=/opt/bellsoft/liberica-vm-22.1.0-openjdk17" >> /etc/profile
12+
RUN echo "export PATH=\"\$JAVA_HOME/bin:\$PATH\"" >> /etc/profile
13+
ENV ENV="/etc/profile"
14+
15+
CMD ["sh"]

Dockerfile.ubuntu

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM ubuntu:16.04
2+
3+
RUN apt-get update
4+
RUN apt-get install -y wget build-essential git libz-dev
5+
RUN wget --no-check-certificate https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.1.0/graalvm-ce-java17-linux-amd64-22.1.0.tar.gz
6+
RUN tar zxvf graalvm-ce-java17-linux-amd64-22.1.0.tar.gz
7+
RUN rm -f graalvm-ce-java17-linux-amd64-22.1.0.tar.gz
8+
RUN mkdir -p /usr/lib/jvm
9+
RUN mv graalvm-ce-java17-22.1.0 /usr/lib/jvm/
10+
RUN /usr/lib/jvm/graalvm-ce-java17-22.1.0/bin/gu install native-image
11+
12+
RUN wget --no-check-certificate https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
13+
RUN tar zxvf apache-maven-3.8.6-bin.tar.gz
14+
RUN rm -f apache-maven-3.8.6-bin.tar.gz
15+
RUN mkdir /opt/maven
16+
RUN mv apache-maven-3.8.6 /opt/maven
17+
18+
19+
RUN echo "" >> /etc/profile
20+
RUN echo "export JAVA_HOME=/usr/lib/jvm/graalvm-ce-java17-22.1.0" >> /etc/profile
21+
RUN echo "export MAVEN_HOME=/opt/maven/apache-maven-3.8.6" >> /etc/profile
22+
RUN echo "export PATH=\"\$JAVA_HOME/bin:\$MAVEN_HOME/bin:\$PATH\"" >> /etc/profile
23+
#ENV ENV="/etc/profile"
24+
25+
CMD ["sh"]

build-alpine-docker.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker build --file Dockerfile.alpine --tag graalvm-alpine .

build-alpine-native-image.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
mvn clean
4+
5+
docker run -it --rm --workdir /project --user "$(id -u):$(id -g)" --volume ${PWD}:/project graalvm-alpine sh --login -c "mvn -Pnative package"
6+
7+
mv target/geoip-server-linux-x86_64 target/geoip-server-alpine-x86_64

build-native-config.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ APP_PID=$!
1313
sleep 2
1414

1515
# hit the server once (one w/ a postal code is key)
16-
curl http://localhost:18080/api/v1/ips/24.192.251.98
16+
curl http://localhost:18888/api/v1/ips/24.192.251.98
1717

1818
# kill the app (mimic CTRL-C)
1919
kill -TERM $APP_PID

build-ubuntu-docker.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker build --file Dockerfile.ubuntu --tag graalvm-ubuntu .

build-ubuntu-native-image.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
mvn clean
4+
5+
docker run -it --rm --workdir /project --user "$(id -u):$(id -g)" --volume ${PWD}:/project graalvm-ubuntu bash --login -c "mvn -Pnative package"

src/main/java/com/fizzed/geoip/GeoipServer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static public void main(String[] args) throws Exception {
5050
parser.addArgument("--port")
5151
.dest("port")
5252
.type(Integer.class)
53-
.setDefault(18080)
53+
.setDefault(18888)
5454
.help("Port to bind server to");
5555
parser.addArgument("--download-every-interval")
5656
.dest("downloadEveryInterval")

0 commit comments

Comments
 (0)