Skip to content

Commit d8a9d18

Browse files
Merge pull request #237 from costateixeira/linux-docker
Linux installer and docker
2 parents f5ea20f + 25a6764 commit d8a9d18

15 files changed

+492
-129
lines changed
+79-87
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,79 @@
1-
on:
2-
# Trigger the workflow on push or pull request,
3-
# but only for the main branch
4-
push:
5-
branches:
6-
- master
7-
# pull_request:
8-
jobs:
9-
Build-Docker-Image:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- name: Check out repository code
13-
uses: actions/checkout@v2
14-
# -
15-
# name: Login to Docker Hub
16-
# uses: docker/login-action@v2
17-
# with:
18-
# username: ${{ secrets.DOCKERHUB_USERNAME }}
19-
# password: ${{ secrets.DOCKERHUB_TOKEN }}
20-
- name: Cache terminology files
21-
uses: actions/cache@v2
22-
with:
23-
path: ~/terminology
24-
key: terminology-${{ github.sha }}
25-
restore-keys: terminology-
26-
- name: Setup MySQL
27-
run: |
28-
docker network create gh
29-
docker run \
30-
--network gh \
31-
--name mysql \
32-
-e MYSQL_ROOT_PASSWORD=test \
33-
-e MYSQL_USER=test \
34-
-e MYSQL_PASSWORD=test \
35-
-e MYSQL_DATABASE=test \
36-
-d mysql:8
37-
- name: Docker Build
38-
run: |
39-
docker build \
40-
--tag fhirserver \
41-
.
42-
# - name: Scan Code
43-
# run: |
44-
# export DISPLAY=0:0
45-
# docker run --entrypoint /work/fhirserver/utilities/codescan/codescan fhirserver /work/bootstrap
46-
- name: Prepare ini file
47-
env:
48-
FHIRSERVER_LOCATIONS_CLONE_PATH: /work/fhirserver
49-
FHIRSERVER_LOCATIONS_TEST_CASES_CLONE_PATH: /work/bootstrap/source/fhir-test-cases
50-
FHIRSERVER_LOCATIONS_MARKDOWN_CLONE_PATH: /work/bootstrap/source/delphi-markdown
51-
FHIRSERVER_LOCATIONS_SNOMED_CACHE_PATH: /terminology/fhir-server/snomed.test.cache
52-
FHIRSERVER_MYSQL_SERVER: mysql
53-
FHIRSERVER_EMAIL_SENDER: [email protected]
54-
FHIRSERVER_EMAIL_DESTINATION: [email protected]
55-
FHIRSERVER_EMAIL_PASSWORD: ${{ secrets.FHIRSERVER_EMAIL_PASSWORD }}
56-
FHIRSERVER_SSL_CERT_PATH: /work/fhirserver/fixtures/domain.crt
57-
FHIRSERVER_SSL_KEY_PATH: /work/fhirserver/fixtures/domain.key
58-
FHIRSERVER_SSL_CACERT_PATH: /work/fhirserver/fixtures/rootCA.crt
59-
FHIRSERVER_SSL_PASSWORD: password
60-
run: |
61-
cat fixtures/test-settings.ini.template | envsubst > ~/test-settings.ini
62-
- name: Ensure SNOMED cache is present
63-
run: |
64-
mkdir -p ~/terminology/fhir-server
65-
wget -q --no-clobber https://storage.googleapis.com/ig-build/snomed.test.cache -O ~/terminology/fhir-server/snomed.test.cache || true
66-
ls ~/terminology/fhir-server/snomed.test.cache
67-
- name: Run tests in docker
68-
run: |
69-
docker images --all
70-
docker run \
71-
--network gh \
72-
-v ~/terminology:/terminology \
73-
-v ~/test-settings.ini:/work/fhirserver/exec/64/test-settings.ini \
74-
fhirserver -tests
75-
76-
# - name: Tag and push Docker image
77-
# run: |
78-
# # Extract the FHIR server version from the library/version.inc file
79-
# FHIR_VERSION=$(grep -oP "FHIR_CODE_FULL_VERSION = '\K[^']+" library/version.inc)
80-
#
81-
# # Tag the Docker image with the extracted version and "latest"
82-
# docker tag fhirserver ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:$FHIR_VERSION
83-
# docker tag fhirserver ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:latest
84-
#
85-
# # Push both tagged images to Docker Hub
86-
# docker push ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:$FHIR_VERSION
87-
# docker push ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:latest
1+
name: Build and Push Docker Image to GHCR
2+
3+
on:
4+
# Trigger the workflow on push or pull request for the main branch
5+
push:
6+
pull_request:
7+
8+
jobs:
9+
Build-Docker-Image:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# Step 1: Check out the repository code
14+
- name: Check out repository code
15+
uses: actions/checkout@v2
16+
17+
# Step 2: Log in to GitHub Container Registry (GHCR)
18+
- name: Log in to GitHub Container Registry
19+
uses: docker/login-action@v2
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub
24+
25+
# Step 3: Cache terminology files (optional, to avoid re-downloading terminology files)
26+
- name: Cache terminology files
27+
uses: actions/cache@v2
28+
with:
29+
path: ~/terminology
30+
key: terminology-${{ github.sha }}
31+
restore-keys: terminology-
32+
33+
# Step 4: Setup MySQL for the build
34+
- name: Setup MySQL
35+
run: |
36+
docker network create gh
37+
docker run \
38+
--network gh \
39+
--name mysql \
40+
-e MYSQL_ROOT_PASSWORD=test \
41+
-e MYSQL_USER=test \
42+
-e MYSQL_PASSWORD=test \
43+
-e MYSQL_DATABASE=test \
44+
-d mysql:8
45+
46+
# Step 5: Build the Docker image and tag it for GitHub Container Registry (GHCR)
47+
- name: Docker Build
48+
run: |
49+
docker build --tag ghcr.io/${{ github.repository_owner }}/fhirserver:nightly .
50+
51+
# Step 6: Prepare ini file for your FHIR Server with environment variables
52+
- name: Prepare ini file
53+
env:
54+
FHIRSERVER_LOCATIONS_CLONE_PATH: /work/fhirserver
55+
FHIRSERVER_LOCATIONS_TEST_CASES_CLONE_PATH: /work/bootstrap/source/fhir-test-cases
56+
FHIRSERVER_LOCATIONS_MARKDOWN_CLONE_PATH: /work/bootstrap/source/delphi-markdown
57+
FHIRSERVER_LOCATIONS_SNOMED_CACHE_PATH: /terminology/fhir-server/snomed.test.cache
58+
FHIRSERVER_MYSQL_SERVER: mysql
59+
FHIRSERVER_EMAIL_SENDER: [email protected]
60+
FHIRSERVER_EMAIL_DESTINATION: [email protected]
61+
FHIRSERVER_EMAIL_PASSWORD: ${{ secrets.FHIRSERVER_EMAIL_PASSWORD }}
62+
FHIRSERVER_SSL_CERT_PATH: /work/fhirserver/fixtures/domain.crt
63+
FHIRSERVER_SSL_KEY_PATH: /work/fhirserver/fixtures/domain.key
64+
FHIRSERVER_SSL_CACERT_PATH: /work/fhirserver/fixtures/rootCA.crt
65+
FHIRSERVER_SSL_PASSWORD: password
66+
run: |
67+
cat fixtures/test-settings.ini.template | envsubst > ~/test-settings.ini
68+
69+
# Step 7: Ensure SNOMED cache is present
70+
- name: Ensure SNOMED cache is present
71+
run: |
72+
mkdir -p ~/terminology/fhir-server
73+
wget -q --no-clobber https://storage.googleapis.com/ig-build/snomed.test.cache -O ~/terminology/fhir-server/snomed.test.cache || true
74+
ls ~/terminology/fhir-server/snomed.test.cache
75+
76+
# Step 8: Push the Docker image to GitHub Container Registry (GHCR)
77+
- name: Push Docker image to GHCR
78+
run: |
79+
docker push ghcr.io/${{ github.repository_owner }}/fhirserver:nightly

Dockerfile

+105-31
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM ubuntu:22.04 as builder
1+
FROM ubuntu:24.04 AS builder
22

33
ENV DEBIAN_FRONTEND=noninteractive
44

55

6-
RUN apt update && apt install -y tzdata wget git unixodbc-dev libgtk2.0-dev xvfb sqlite3 libsqlite3-dev build-essential curl
6+
RUN apt update && apt-get upgrade -y && apt install -y tzdata wget git unixodbc-dev libgtk2.0-dev xvfb sqlite3 libsqlite3-dev build-essential curl binutils && apt-get clean && rm -rf /var/lib/apt/lists/*
77

88
# Download and build OpenSSL 1.1.1w
99
WORKDIR /tmp
@@ -15,7 +15,7 @@ RUN wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz \
1515
&& make test \
1616
&& make install
1717

18-
RUN ls -la /usr/local/lib/
18+
# RUN ls -la /usr/local/lib/
1919

2020
# Set the timezone
2121
RUN echo "UTC" > /etc/timezone
@@ -36,40 +36,114 @@ RUN /work/bootstrap/linux-toolchain.sh /work/bootstrap
3636
WORKDIR /work/fhirserver
3737
COPY . /work/fhirserver
3838

39-
RUN /work/bootstrap/linux-libraries.sh /work/bootstrap
40-
RUN cp /usr/local/lib/*.so* /usr/lib/
41-
RUN /work/fhirserver/build/linux-fhirserver.sh /work/bootstrap
42-
RUN cp exec/pack/*.properties exec/64
39+
RUN /work/bootstrap/linux-libraries.sh /work/bootstrap && \
40+
cp /usr/local/lib/*.so* /usr/lib/ && \
41+
/work/fhirserver/build/linux-fhirserver.sh /work/bootstrap && \
42+
cp exec/pack/*.properties exec/64
43+
# RUN cp exec/install/* exec/64
44+
45+
RUN mkdir -p /work/fhirserver/exec/install/bin && \
46+
mkdir -p /work/fhirserver/exec/install/x86_64 && \
47+
mkdir -p /work/fhirserver/exec/install/content && \
48+
mkdir -p /work/fhirserver/exec/install/config && \
49+
# mkdir -p /work/fhirserver/exec/install/config/config && \
50+
mkdir -p /work/fhirserver/exec/install/default_config && \
51+
mkdir -p /work/fhirserver/exec/install/web
52+
53+
RUN cd /work/fhirserver && \
54+
cp /work/fhirserver/exec/64/fhirserver /work/fhirserver/exec/install/bin && \
55+
cp /work/fhirserver/exec/64/FHIRToolkit /work/fhirserver/exec/install/bin && \
56+
cp /work/fhirserver/exec/64/FHIRConsole /work/fhirserver/exec/install/bin && \
57+
cp /work/fhirserver/exec/pack/linux/*so* /work/fhirserver/exec/install/x86_64
58+
59+
RUN cp /work/fhirserver/exec/pack/linux/start.sh /work/fhirserver/exec/install/bin/start.sh && \
60+
cp /work/fhirserver/exec/pack/linux/install.sh /work/fhirserver/exec/install && \
61+
cp /work/fhirserver/exec/pack/linux/get-openssl.sh /work/fhirserver/exec/install && \
62+
cp /tmp/openssl-1.1.1w/*.so* /work/fhirserver/exec/install/x86_64 && \
63+
cp /work/fhirserver/exec/pack/*.properties /work/fhirserver/exec/install/content && \
64+
cp /work/fhirserver/exec/pack/*.dat /work/fhirserver/exec/install/content && \
65+
66+
cp /work/fhirserver/exec/pack/fhirserver.cfg /work/fhirserver/exec/install/config && \
67+
cp /work/fhirserver/exec/pack/web.ini /work/fhirserver/exec/install/config && \
68+
69+
70+
cp /work/fhirserver/exec/pack/web.ini /work/fhirserver/exec/install/default_config && \
71+
cp /work/fhirserver/exec/pack/fhirserver.cfg /work/fhirserver/exec/install/default_config && \
72+
cp /work/fhirserver/config/config.ini /work/fhirserver/exec/install/default_config/config.ini && \
73+
cp /work/fhirserver/config/config.json /work/fhirserver/exec/install/default_config/config.json && \
74+
# cp /work/fhirserver/config/config.ini /work/fhirserver/exec/install/config/config.ini && \
75+
76+
# cp /work/fhirserver/config/config_bare.json /work/fhirserver/exec/install/default_config/config.json && \
77+
# cp /work/fhirserver/config/config.ini /work/fhirserver/exec/install/config/default_config && \
78+
79+
mkdir -p /work/fhirserver/exec/install/web && \
80+
cp -r /work/fhirserver/server/web/* /work/fhirserver/exec/install/web && \
81+
cd /work/fhirserver/exec && tar -czvf ./install.tgz ./install/ && ls -la /work/fhirserver/exec
82+
4383

4484
# Set the health check
45-
HEALTHCHECK --interval=1m --timeout=10s --retries=5 \
85+
HEALTHCHECK --interval=1m --timeout=10s --retries=5 \
4686
CMD curl -f http://localhost:${PORT}/fhir/metadata || exit 1
4787

4888
# Set the environment variables
49-
ENV DISPLAY :99
50-
ENV PORT 80
51-
ENV TERMINOLOGY_CACHE /terminology
89+
ENV DISPLAY=:99
90+
ENV PORT=80
91+
ENV TERMINOLOGY_CACHE=/terminology
5292
VOLUME /terminology
5393

5494
ENV DEBIAN_FRONTEND=
5595

56-
RUN printf '#!/bin/bash \n\
57-
set -e \n\
58-
start_xvfb() { \n\
59-
Xvfb :99 -screen 0 1024x768x8 -nolisten tcp & \n\
60-
} \n\
61-
stop_xvfb() { \n\
62-
killall Xvfb || true \n\
63-
} \n\
64-
trap stop_xvfb SIGTERM \n\
65-
rm -f /tmp/.X99-lock \n\
66-
start_xvfb \n\
67-
echo "[web]" > /work/fhirserver/exec/64/web.ini; \n\
68-
echo "http=${PORT}" >> /work/fhirserver/exec/64/web.ini; \n\
69-
/work/fhirserver/exec/64/fhirserver $(eval echo "$@")' > /bin/entrypoint.sh && \
70-
chmod +x /bin/entrypoint.sh
71-
72-
73-
ENTRYPOINT ["/bin/entrypoint.sh"]
74-
75-
CMD ["-cmd", "exec", "-cfg", "/config/config.ini", "-local", "$TERMINOLOGY_CACHE"]
96+
# ENTRYPOINT ["/bin/entrypoint.sh"]
97+
98+
# CMD ["-cmd", "exec", "-cfg", "/config/config.ini", "-local", "$TERMINOLOGY_CACHE"]
99+
100+
101+
102+
# Runtime stage
103+
FROM ubuntu:24.04 AS runtime
104+
105+
ENV DEBIAN_FRONTEND=noninteractive
106+
ENV TZ=UTC
107+
# Set up environment variables
108+
# ENV HOME=~/
109+
ENV DISPLAY=:99
110+
ENV PORT=80
111+
ENV TERMINOLOGY_CACHE=/var/cache/txcache
112+
113+
# Install runtime dependencies
114+
RUN apt-get update && apt-get upgrade -y && apt-get install -y wget tzdata xvfb libgtk2.0-0 libsqlite3-dev curl && apt-get clean \
115+
&& rm -rf /var/lib/apt/lists/* \
116+
&& mkdir -p $HOME/fhirserver/config $TERMINOLOGY_CACHE /fhirserver \
117+
&& chmod -R 777 $TERMINOLOGY_CACHE \
118+
&& chmod -R 777 /fhirserver
119+
120+
# Copy necessary files from the builder stage
121+
COPY --from=builder /work/fhirserver/exec/install.tgz /fhirserver/install.tgz
122+
123+
# RUN cd /fhirserver \
124+
# && tar -xzvf install.tgz \
125+
# && cd ./install \
126+
# && ./install.sh > install.log 2>&1
127+
128+
# Assuming /fhirserver is your working directory
129+
WORKDIR /fhirserver
130+
131+
# Extract the contents of the tar file
132+
RUN tar -xzvf install.tgz
133+
134+
# Change working directory to the extracted folder
135+
WORKDIR /fhirserver/install
136+
137+
138+
# Run the installation script for a blank, clean install
139+
RUN chmod a+x ./install.sh && ./install.sh
140+
141+
####################################################################
142+
143+
WORKDIR /root/fhirserver
144+
145+
# Define entrypoint and command
146+
CMD ["bash", "-c", "cd ~/fhirserver/ && ./start.sh"]
147+
148+
# Expose the necessary port
149+
EXPOSE 80

0 commit comments

Comments
 (0)