diff --git a/.github/workflows/linux-docker-build.yml b/.github/workflows/linux-docker-build.yml index f261596d2..8164af372 100644 --- a/.github/workflows/linux-docker-build.yml +++ b/.github/workflows/linux-docker-build.yml @@ -33,9 +33,10 @@ jobs: docker build \ --tag fhirserver \ . - - name: Scan Code - run: | - docker run --entrypoint /work/fhirserver/utilities/codescan/codescan fhirserver /work/bootstrap +# - 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 @@ -65,3 +66,15 @@ jobs: -v ~/terminology:/terminology \ -v ~/test-settings.ini:/work/fhirserver/exec/64/test-settings.ini \ fhirserver -tests + - + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Tag and push Docker image + run: | + docker tag fhirserver ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:latest + docker push ${{ secrets.DOCKERHUB_USERNAME }}/fhirserver:latest + diff --git a/Dockerfile b/Dockerfile index 940acbfc4..ee737bdf9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,10 +19,12 @@ RUN /work/bootstrap/linux-toolchain.sh /work/bootstrap WORKDIR /work/fhirserver COPY . /work/fhirserver -RUN /work/bootstrap/linux-libraries.sh /work/bootstrap -RUN cp exec/pack/linux/*.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 exec/pack/linux/*.so /usr/lib/ +RUN /work/fhirserver/build/linux-fhirserver.sh /work/bootstrap && \ + cp exec/pack/*.properties exec/64 && \ + find . -name "*.o" -type f -delete -o -name "*.ppu" -type f -delete + ENV DISPLAY :99 ENV PORT 80 @@ -38,4 +40,4 @@ chmod +x /bin/entrypoint.sh ENTRYPOINT ["/bin/entrypoint.sh"] -CMD ["-cmd", "exec", "-cfg", "http://tx.fhir.org/config", "-version", "4", "-local", "$TERMINOLOGY_CACHE"] +CMD ["-cmd", "exec", "-cfg", "/config/config.ini", "-local", "$TERMINOLOGY_CACHE"] diff --git a/config/config.ini b/config/config.ini new file mode 100644 index 000000000..dff35689b --- /dev/null +++ b/config/config.ini @@ -0,0 +1,6 @@ +[config] +zero=https://storage.googleapis.com/tx-fhir-org +version=* +user=jose + +[web] diff --git a/library/ftx/ftx_loinc_services.pas b/library/ftx/ftx_loinc_services.pas index 1e4322261..2dbdf7deb 100644 --- a/library/ftx/ftx_loinc_services.pas +++ b/library/ftx/ftx_loinc_services.pas @@ -35,7 +35,8 @@ Uses SysUtils, Classes, Generics.Collections, {$IFDEF FPC} LazUTF8,{$ELSE} IOUtils, RegularExpressions, {$ENDIF} fsl_base, fsl_utilities, fsl_stream, fsl_collections, fsl_fpc, fsl_lang, fsl_http, - fhir_objects, fhir_common, fhir_utilities, fhir_factory, fhir_features, fhir_uris, + fhir_objects, fhir_common, fhir_utilities, fhir_factory, + fhir_features, fhir_uris, fhir_cdshooks, ftx_service; @@ -525,6 +526,13 @@ function memU16ToString(const bytes : TBytes; index : cardinal; chars : word) : // the bytes contain UTF8 function memU8toString(bytes : TBytes; index, chars : integer) : String; +{$IFNDEF FPC} +var + utf8str: UTF8String; +{$ENDIF} + var UTFEncoding: TEncoding; + theseBytes:TBytes; + begin if chars = 0 then exit(''); @@ -534,7 +542,13 @@ function memU8toString(bytes : TBytes; index, chars : integer) : String; setLength(result, chars); Move(bytes[index], result[1], chars); {$ELSE} - result := TEncoding.UTF8.GetString(bytes, index, chars); + UTFEncoding:= TEncoding.UTF8; + theseBytes := Copy(bytes, index, chars); + try + result :=UTFEncoding.GetString(theseBytes); + except + writeln(result) + end; {$ENDIF} end; diff --git a/library/ftx/ftx_sct_services.pas b/library/ftx/ftx_sct_services.pas index 5b13e9b68..f30b0717c 100644 --- a/library/ftx/ftx_sct_services.pas +++ b/library/ftx/ftx_sct_services.pas @@ -58,7 +58,7 @@ } Uses - SysUtils, Classes, Generics.Collections, Character, + SysUtils, Classes, Generics.Collections, Character, Dialogs, fsl_base, fsl_utilities, fsl_collections, fsl_http, fsl_fpc, fsl_threads, fsl_lang, fhir_objects, fhir_common, fhir_factory, fhir_utilities, fhir_features, fhir_uris, fhir_cdshooks, @@ -840,7 +840,7 @@ function TSnomedStrings.GetEntry(iIndex: Cardinal): String; if FIsUTF16 then result := memU16ToString(FMaster, iIndex+2, i) else - result := memU8ToString(FMaster, iIndex+2, i) + result := memU8ToString(FMaster, iIndex+2, i) end; procedure TSnomedStrings.Reopen; @@ -852,15 +852,16 @@ procedure TSnomedStrings.Reopen; function TSnomedStrings.AddString(const s: String): Cardinal; var i : word; - b : TArray; + b : TBytes; begin if Length(s) > 65535 Then raise ETerminologySetup.Create('Snomed Description too long: '+String(s)); result := FBuilder.Length; if FIsUTF16 then b := TEncoding.BigEndianUnicode.GetBytes(s) - else - b := TEncoding.UTF8.GetBytes(s); + else + b := TEncoding.UTF8.GetBytes(s) ; + i := length(b); FBuilder.AddWord(i); FBuilder.Append(b); diff --git a/server/fhirconsole.lpi b/server/fhirconsole.lpi index df3c0694d..1016b41e4 100644 --- a/server/fhirconsole.lpi +++ b/server/fhirconsole.lpi @@ -143,6 +143,9 @@ + + -O2 -Xs + diff --git a/server/fhirserver.lpi b/server/fhirserver.lpi index 862d871a7..210cdf98d 100644 --- a/server/fhirserver.lpi +++ b/server/fhirserver.lpi @@ -168,6 +168,7 @@ + -O2 -Xs diff --git a/server/web_base.pas b/server/web_base.pas index 9c917f586..ab34a7376 100644 --- a/server/web_base.pas +++ b/server/web_base.pas @@ -432,7 +432,9 @@ function TFHIRWebServerBase.IsTerminologyServerOnly: boolean; result := 'video/mpeg' Else if AExt = '.js' Then result := 'text/javascript' - Else + else if AExt = '.html' then // Add this case + result := 'text/html' // Use 'text/html' for .html files + else Begin {$IFDEF WINDOWS} Try diff --git a/server/web_server.pas b/server/web_server.pas index 23bfa40bb..cafba3d4f 100644 --- a/server/web_server.pas +++ b/server/web_server.pas @@ -677,7 +677,18 @@ procedure TFhirWebServer.PlainRequest(AContext: TIdContext; ok : boolean; epn, cid, ip : String; tt : TTimeTracker; + fullPath: String; + DefaultFiles: array[0..2] of String; + DefaultFile: String; + i: Integer; + begin + + DefaultFiles[0] := 'index.html'; + DefaultFiles[1] := 'index.htm'; + DefaultFiles[2] := 'default.html'; + + // when running with a reverse proxy, it's easier to let the reverse proxy just use non-ssl upstream, and pass through the certificate details se we know SSL is being used if (Common.SSLHeaderValue <> '') and (request.RawHeaders.Values['X-Client-SSL'] = Common.SSLHeaderValue) then SecureRequest(aContext, request, response) @@ -742,6 +753,23 @@ procedure TFhirWebServer.PlainRequest(AContext: TIdContext; if not ok then begin + // Get full path of the requested document + fullPath := SourceProvider.AltFile(request.Document, '/'); + + // If the path corresponds to a directory, look for a default file + if DirectoryExists(fullPath) then + begin + for i := 0 to 2 do + begin + DefaultFile := DefaultFiles[i]; + if FileExists(fullPath + '/' + DefaultFile) then + begin + ReturnSpecFile(response, request.Document + '/' + DefaultFile, fullPath + '/' + DefaultFile, false); + Exit; // Exit the procedure after serving a default file + end; + end; + end; + if request.Document = '/diagnostics' then begin epn := 'WS'; diff --git a/toolkit2/fhirtoolkit.lpi b/toolkit2/fhirtoolkit.lpi index b4088df07..cbf1aef44 100644 --- a/toolkit2/fhirtoolkit.lpi +++ b/toolkit2/fhirtoolkit.lpi @@ -118,6 +118,7 @@ + -O2 -Xs diff --git a/utilities/codescan/codescan.lpi b/utilities/codescan/codescan.lpi index 6063e96a2..6576e515e 100644 --- a/utilities/codescan/codescan.lpi +++ b/utilities/codescan/codescan.lpi @@ -53,6 +53,9 @@ + + -O2 -Xs +