Skip to content

Commit

Permalink
Merge pull request #237 from costateixeira/linux-docker
Browse files Browse the repository at this point in the history
Linux installer and docker
  • Loading branch information
grahamegrieve authored Sep 27, 2024
2 parents f5ea20f + 25a6764 commit d8a9d18
Show file tree
Hide file tree
Showing 15 changed files with 492 additions and 129 deletions.
166 changes: 79 additions & 87 deletions .github/workflows/linux-docker-build.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,79 @@
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- master
# pull_request:
jobs:
Build-Docker-Image:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
# -
# name: Login to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Cache terminology files
uses: actions/cache@v2
with:
path: ~/terminology
key: terminology-${{ github.sha }}
restore-keys: terminology-
- name: Setup MySQL
run: |
docker network create gh
docker run \
--network gh \
--name mysql \
-e MYSQL_ROOT_PASSWORD=test \
-e MYSQL_USER=test \
-e MYSQL_PASSWORD=test \
-e MYSQL_DATABASE=test \
-d mysql:8
- name: Docker Build
run: |
docker build \
--tag fhirserver \
.
# - name: Scan Code
# run: |
# export DISPLAY=0:0
# docker run --entrypoint /work/fhirserver/utilities/codescan/codescan fhirserver /work/bootstrap
- name: Prepare ini file
env:
FHIRSERVER_LOCATIONS_CLONE_PATH: /work/fhirserver
FHIRSERVER_LOCATIONS_TEST_CASES_CLONE_PATH: /work/bootstrap/source/fhir-test-cases
FHIRSERVER_LOCATIONS_MARKDOWN_CLONE_PATH: /work/bootstrap/source/delphi-markdown
FHIRSERVER_LOCATIONS_SNOMED_CACHE_PATH: /terminology/fhir-server/snomed.test.cache
FHIRSERVER_MYSQL_SERVER: mysql
FHIRSERVER_EMAIL_SENDER: [email protected]
FHIRSERVER_EMAIL_DESTINATION: [email protected]
FHIRSERVER_EMAIL_PASSWORD: ${{ secrets.FHIRSERVER_EMAIL_PASSWORD }}
FHIRSERVER_SSL_CERT_PATH: /work/fhirserver/fixtures/domain.crt
FHIRSERVER_SSL_KEY_PATH: /work/fhirserver/fixtures/domain.key
FHIRSERVER_SSL_CACERT_PATH: /work/fhirserver/fixtures/rootCA.crt
FHIRSERVER_SSL_PASSWORD: password
run: |
cat fixtures/test-settings.ini.template | envsubst > ~/test-settings.ini
- name: Ensure SNOMED cache is present
run: |
mkdir -p ~/terminology/fhir-server
wget -q --no-clobber https://storage.googleapis.com/ig-build/snomed.test.cache -O ~/terminology/fhir-server/snomed.test.cache || true
ls ~/terminology/fhir-server/snomed.test.cache
- name: Run tests in docker
run: |
docker images --all
docker run \
--network gh \
-v ~/terminology:/terminology \
-v ~/test-settings.ini:/work/fhirserver/exec/64/test-settings.ini \
fhirserver -tests
# - name: Tag and push Docker image
# run: |
# # Extract the FHIR server version from the library/version.inc file
# FHIR_VERSION=$(grep -oP "FHIR_CODE_FULL_VERSION = '\K[^']+" library/version.inc)
#
# # Tag the Docker image with the extracted version and "latest"
# docker tag fhirserver ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:$FHIR_VERSION
# docker tag fhirserver ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:latest
#
# # Push both tagged images to Docker Hub
# docker push ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:$FHIR_VERSION
# docker push ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:latest
name: Build and Push Docker Image to GHCR

on:
# Trigger the workflow on push or pull request for the main branch
push:
pull_request:

jobs:
Build-Docker-Image:
runs-on: ubuntu-latest

steps:
# Step 1: Check out the repository code
- name: Check out repository code
uses: actions/checkout@v2

# Step 2: Log in to GitHub Container Registry (GHCR)
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub

# Step 3: Cache terminology files (optional, to avoid re-downloading terminology files)
- name: Cache terminology files
uses: actions/cache@v2
with:
path: ~/terminology
key: terminology-${{ github.sha }}
restore-keys: terminology-

# Step 4: Setup MySQL for the build
- name: Setup MySQL
run: |
docker network create gh
docker run \
--network gh \
--name mysql \
-e MYSQL_ROOT_PASSWORD=test \
-e MYSQL_USER=test \
-e MYSQL_PASSWORD=test \
-e MYSQL_DATABASE=test \
-d mysql:8
# Step 5: Build the Docker image and tag it for GitHub Container Registry (GHCR)
- name: Docker Build
run: |
docker build --tag ghcr.io/${{ github.repository_owner }}/fhirserver:nightly .
# Step 6: Prepare ini file for your FHIR Server with environment variables
- name: Prepare ini file
env:
FHIRSERVER_LOCATIONS_CLONE_PATH: /work/fhirserver
FHIRSERVER_LOCATIONS_TEST_CASES_CLONE_PATH: /work/bootstrap/source/fhir-test-cases
FHIRSERVER_LOCATIONS_MARKDOWN_CLONE_PATH: /work/bootstrap/source/delphi-markdown
FHIRSERVER_LOCATIONS_SNOMED_CACHE_PATH: /terminology/fhir-server/snomed.test.cache
FHIRSERVER_MYSQL_SERVER: mysql
FHIRSERVER_EMAIL_SENDER: [email protected]
FHIRSERVER_EMAIL_DESTINATION: [email protected]
FHIRSERVER_EMAIL_PASSWORD: ${{ secrets.FHIRSERVER_EMAIL_PASSWORD }}
FHIRSERVER_SSL_CERT_PATH: /work/fhirserver/fixtures/domain.crt
FHIRSERVER_SSL_KEY_PATH: /work/fhirserver/fixtures/domain.key
FHIRSERVER_SSL_CACERT_PATH: /work/fhirserver/fixtures/rootCA.crt
FHIRSERVER_SSL_PASSWORD: password
run: |
cat fixtures/test-settings.ini.template | envsubst > ~/test-settings.ini
# Step 7: Ensure SNOMED cache is present
- name: Ensure SNOMED cache is present
run: |
mkdir -p ~/terminology/fhir-server
wget -q --no-clobber https://storage.googleapis.com/ig-build/snomed.test.cache -O ~/terminology/fhir-server/snomed.test.cache || true
ls ~/terminology/fhir-server/snomed.test.cache
# Step 8: Push the Docker image to GitHub Container Registry (GHCR)
- name: Push Docker image to GHCR
run: |
docker push ghcr.io/${{ github.repository_owner }}/fhirserver:nightly
136 changes: 105 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM ubuntu:22.04 as builder
FROM ubuntu:24.04 AS builder

ENV DEBIAN_FRONTEND=noninteractive


RUN apt update && apt install -y tzdata wget git unixodbc-dev libgtk2.0-dev xvfb sqlite3 libsqlite3-dev build-essential curl
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/*

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

RUN ls -la /usr/local/lib/
# RUN ls -la /usr/local/lib/

# Set the timezone
RUN echo "UTC" > /etc/timezone
Expand All @@ -36,40 +36,114 @@ RUN /work/bootstrap/linux-toolchain.sh /work/bootstrap
WORKDIR /work/fhirserver
COPY . /work/fhirserver

RUN /work/bootstrap/linux-libraries.sh /work/bootstrap
RUN cp /usr/local/lib/*.so* /usr/lib/
RUN /work/fhirserver/build/linux-fhirserver.sh /work/bootstrap
RUN cp exec/pack/*.properties exec/64
RUN /work/bootstrap/linux-libraries.sh /work/bootstrap && \
cp /usr/local/lib/*.so* /usr/lib/ && \
/work/fhirserver/build/linux-fhirserver.sh /work/bootstrap && \
cp exec/pack/*.properties exec/64
# RUN cp exec/install/* exec/64

RUN mkdir -p /work/fhirserver/exec/install/bin && \
mkdir -p /work/fhirserver/exec/install/x86_64 && \
mkdir -p /work/fhirserver/exec/install/content && \
mkdir -p /work/fhirserver/exec/install/config && \
# mkdir -p /work/fhirserver/exec/install/config/config && \
mkdir -p /work/fhirserver/exec/install/default_config && \
mkdir -p /work/fhirserver/exec/install/web

RUN cd /work/fhirserver && \
cp /work/fhirserver/exec/64/fhirserver /work/fhirserver/exec/install/bin && \
cp /work/fhirserver/exec/64/FHIRToolkit /work/fhirserver/exec/install/bin && \
cp /work/fhirserver/exec/64/FHIRConsole /work/fhirserver/exec/install/bin && \
cp /work/fhirserver/exec/pack/linux/*so* /work/fhirserver/exec/install/x86_64

RUN cp /work/fhirserver/exec/pack/linux/start.sh /work/fhirserver/exec/install/bin/start.sh && \
cp /work/fhirserver/exec/pack/linux/install.sh /work/fhirserver/exec/install && \
cp /work/fhirserver/exec/pack/linux/get-openssl.sh /work/fhirserver/exec/install && \
cp /tmp/openssl-1.1.1w/*.so* /work/fhirserver/exec/install/x86_64 && \
cp /work/fhirserver/exec/pack/*.properties /work/fhirserver/exec/install/content && \
cp /work/fhirserver/exec/pack/*.dat /work/fhirserver/exec/install/content && \

cp /work/fhirserver/exec/pack/fhirserver.cfg /work/fhirserver/exec/install/config && \
cp /work/fhirserver/exec/pack/web.ini /work/fhirserver/exec/install/config && \


cp /work/fhirserver/exec/pack/web.ini /work/fhirserver/exec/install/default_config && \
cp /work/fhirserver/exec/pack/fhirserver.cfg /work/fhirserver/exec/install/default_config && \
cp /work/fhirserver/config/config.ini /work/fhirserver/exec/install/default_config/config.ini && \
cp /work/fhirserver/config/config.json /work/fhirserver/exec/install/default_config/config.json && \
# cp /work/fhirserver/config/config.ini /work/fhirserver/exec/install/config/config.ini && \

# cp /work/fhirserver/config/config_bare.json /work/fhirserver/exec/install/default_config/config.json && \
# cp /work/fhirserver/config/config.ini /work/fhirserver/exec/install/config/default_config && \

mkdir -p /work/fhirserver/exec/install/web && \
cp -r /work/fhirserver/server/web/* /work/fhirserver/exec/install/web && \
cd /work/fhirserver/exec && tar -czvf ./install.tgz ./install/ && ls -la /work/fhirserver/exec


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

# Set the environment variables
ENV DISPLAY :99
ENV PORT 80
ENV TERMINOLOGY_CACHE /terminology
ENV DISPLAY=:99
ENV PORT=80
ENV TERMINOLOGY_CACHE=/terminology
VOLUME /terminology

ENV DEBIAN_FRONTEND=

RUN printf '#!/bin/bash \n\
set -e \n\
start_xvfb() { \n\
Xvfb :99 -screen 0 1024x768x8 -nolisten tcp & \n\
} \n\
stop_xvfb() { \n\
killall Xvfb || true \n\
} \n\
trap stop_xvfb SIGTERM \n\
rm -f /tmp/.X99-lock \n\
start_xvfb \n\
echo "[web]" > /work/fhirserver/exec/64/web.ini; \n\
echo "http=${PORT}" >> /work/fhirserver/exec/64/web.ini; \n\
/work/fhirserver/exec/64/fhirserver $(eval echo "$@")' > /bin/entrypoint.sh && \
chmod +x /bin/entrypoint.sh


ENTRYPOINT ["/bin/entrypoint.sh"]

CMD ["-cmd", "exec", "-cfg", "/config/config.ini", "-local", "$TERMINOLOGY_CACHE"]
# ENTRYPOINT ["/bin/entrypoint.sh"]

# CMD ["-cmd", "exec", "-cfg", "/config/config.ini", "-local", "$TERMINOLOGY_CACHE"]



# Runtime stage
FROM ubuntu:24.04 AS runtime

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
# Set up environment variables
# ENV HOME=~/
ENV DISPLAY=:99
ENV PORT=80
ENV TERMINOLOGY_CACHE=/var/cache/txcache

# Install runtime dependencies
RUN apt-get update && apt-get upgrade -y && apt-get install -y wget tzdata xvfb libgtk2.0-0 libsqlite3-dev curl && apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p $HOME/fhirserver/config $TERMINOLOGY_CACHE /fhirserver \
&& chmod -R 777 $TERMINOLOGY_CACHE \
&& chmod -R 777 /fhirserver

# Copy necessary files from the builder stage
COPY --from=builder /work/fhirserver/exec/install.tgz /fhirserver/install.tgz

# RUN cd /fhirserver \
# && tar -xzvf install.tgz \
# && cd ./install \
# && ./install.sh > install.log 2>&1

# Assuming /fhirserver is your working directory
WORKDIR /fhirserver

# Extract the contents of the tar file
RUN tar -xzvf install.tgz

# Change working directory to the extracted folder
WORKDIR /fhirserver/install


# Run the installation script for a blank, clean install
RUN chmod a+x ./install.sh && ./install.sh

####################################################################

WORKDIR /root/fhirserver

# Define entrypoint and command
CMD ["bash", "-c", "cd ~/fhirserver/ && ./start.sh"]

# Expose the necessary port
EXPOSE 80
Loading

0 comments on commit d8a9d18

Please sign in to comment.