Skip to content

Commit 6786a8a

Browse files
authored
Add Dockerfile (#1056)
* Add dockerfile * Document docker usage * Don't run Docker app as root * Add HEALTHCHECK * Add docker test * Fix name + trigger * Try better fetch depth * Try BUILDKIT_CONTEXT_KEEP_GIT_DIR * Move HEALTHCHECK, update maven, install sushi
1 parent 37c3cb1 commit 6786a8a

3 files changed

Lines changed: 89 additions & 2 deletions

File tree

.github/workflows/docker.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This workflow will build the Java project with Maven and peform IntelliJ smoke tests
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: Docker Build
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
pull_request:
11+
branches:
12+
- master
13+
14+
jobs:
15+
docker-build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout project
20+
uses: actions/checkout@v4
21+
- name: Build (no push)
22+
uses: docker/build-push-action@v6
23+
with:
24+
push: false
25+
tags: user/app:latest
26+
build-args: |
27+
BUILDKIT_CONTEXT_KEEP_GIT_DIR=true

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM maven:3.9.9-eclipse-temurin-11 AS build
2+
WORKDIR /build
3+
COPY lib ./lib
4+
COPY pom.xml ./pom.xml
5+
COPY org.hl7.fhir.publisher.cli/pom.xml ./org.hl7.fhir.publisher.cli/pom.xml
6+
COPY org.hl7.fhir.publisher.core/pom.xml ./org.hl7.fhir.publisher.core/pom.xml
7+
RUN mvn dependency:go-offline
8+
COPY . .
9+
RUN mvn install -Dmaven.test.skip=true
10+
11+
FROM eclipse-temurin:11
12+
WORKDIR /app
13+
14+
USER root
15+
16+
ENV APPLICATION_USER=igpublisher
17+
RUN adduser $APPLICATION_USER
18+
19+
RUN chown -R $APPLICATION_USER /app
20+
21+
RUN mkdir /home/$APPLICATION_USER/.fhir
22+
RUN chown -R $APPLICATION_USER /home/$APPLICATION_USER/.fhir
23+
24+
RUN apt-get update && \
25+
apt-get install -y --no-install-recommends git ruby-full build-essential zlib1g-dev nodejs npm && \
26+
apt-get clean && \
27+
rm -rf /var/lib/apt/lists/* && \
28+
npm install -g fsh-sushi && \
29+
gem install jekyll
30+
31+
USER $APPLICATION_USER
32+
COPY --from=build /build/org.hl7.fhir.publisher.cli/target/org.hl7.fhir.publisher.cli-*-SNAPSHOT.jar /app/org.hl7.fhir.publisher.cli.jar
33+
HEALTHCHECK CMD java -jar /app/org.hl7.fhir.publisher.cli.jar
34+
ENTRYPOINT ["java", "-jar", "/app/org.hl7.fhir.publisher.cli.jar"]

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ You can find detailed instructions on setting up this project in your IDE [here]
4242

4343
This project uses [Apache Maven][Link-Maven] to build. To build:
4444

45-
```
45+
```shell
4646
mvn install
4747
```
4848

4949
To skip unit tests:
5050

51-
```
51+
```shell
5252
mvn -Dmaven.test.skip install
5353
```
5454

@@ -61,6 +61,32 @@ In addition, two common publishing tasks that can be accomplished using the fhir
6161
* [Publishing Packages](https://hl7.github.io/docs/ig_publisher/publishing-packages)
6262
* [Publishing Templates](https://hl7.github.io/docs/ig_publisher/publishing-templates)
6363

64+
## Docker
65+
66+
A Dockerfile exists for packaging the IG Publisher and its pre-requisite software as a Docker image.
67+
68+
To build the Docker image from within the project directory:
69+
70+
```shell
71+
docker build -t fhir-ig-publisher:test .
72+
```
73+
74+
You can use `docker run` to run the built docker image. Arguments in the Docker run command will be passed to the
75+
IG Publisher CLI. If you include the --rm parameter, the container by the run command generated will be removed after
76+
the command has been executed. If you wish to debug the container after a run, exclude this parameter.
77+
78+
```shell
79+
docker run --rm fhir-ig-publisher:test
80+
```
81+
82+
*Note: you will have to mount local files and directories in order for them to be accessed by the Docker container.*
83+
84+
```shell
85+
docker run --mount type=bind,src=/path/to/an/ig-directory,dst=/usr/src/ig --rm fhir-ig-publisher:test -ig /usr/src/ig
86+
```
87+
88+
89+
6490
## Releases
6591

6692
The built binary for the FHIR IG publisher is released through [GitHub releases][Link-GithubReleases] and can be downloaded directly [here][Link-GithubZipRelease].

0 commit comments

Comments
 (0)