Skip to content

Commit

Permalink
basic-server: build a container for simple testing
Browse files Browse the repository at this point in the history
Motivation:
In some dev environments running a container is the preferred way, so,
let provide one.

Modification:
Introduce multi-stage container for small image.

Result:

```bash
podman run -p 2049:2049 --name nfs-server docker.io/dcache/nfs4j-server:latest
```

Acked-by: Lea Morschel
Target: master
  • Loading branch information
kofemann committed Jan 27, 2025
1 parent e77f5ad commit 28c3bb0
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
29 changes: 29 additions & 0 deletions basic-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,35 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.45.1</version>
<configuration>
<images>
<image>
<name>%g/nfs4j-server:%l</name>
<build>
<dockerFile>${project.basedir}/src/main/container/Dockerfile</dockerFile>
<assembly>
<descriptorRef>artifact-with-dependencies</descriptorRef>
</assembly>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>build</id>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand Down
29 changes: 29 additions & 0 deletions basic-server/src/main/container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM almalinux:9-minimal as builder

# Add JRE
RUN microdnf -y install java-17-openjdk-devel java-17-openjdk-jmods binutils
RUN jlink -v --compress=2 --strip-debug --no-header-files --no-man-pages --add-modules java.base,java.compiler,java.instrument,java.logging,java.management,java.naming,java.security.jgss,java.transaction.xa,java.xml,jdk.jfr,jdk.security.auth,jdk.unsupported --output /jlink-runtime


FROM almalinux:9-minimal
COPY --from=builder /jlink-runtime /jlink-runtime

# add external files into container at the build time
COPY run.sh /run.sh
RUN chmod +x /run.sh

# where we store the data
RUN mkdir -p /usr/share/nfs4j

# Add JARS
COPY maven /usr/share/nfs4j/jars


# Post-install brutal cleanup
RUN microdnf clean all && rm -rf /var/cache/yum /var/lib/dnf /var/lib/rpm

# expose TCP ports for network services
EXPOSE 2049

# by default we start server
CMD ["/run.sh"]
5 changes: 5 additions & 0 deletions basic-server/src/main/container/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

exec /jlink-runtime/bin/java \
${JAVA_OPT} ${JMX} ${JAVA_ARGS} \
-cp "/usr/share/nfs4j/jars/*" org.dcache.nfs4j.server.Main "$@"

0 comments on commit 28c3bb0

Please sign in to comment.