Skip to content

Commit

Permalink
Still not serving properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Dokotela committed Nov 20, 2024
1 parent d1c9ce5 commit 4eeda64
Show file tree
Hide file tree
Showing 5 changed files with 408 additions and 64 deletions.
39 changes: 39 additions & 0 deletions build/build_fhir_ant.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Ensure Go modules are initialized
if [ ! -f go.mod ]; then
go mod init pocketfhir
fi

# Install necessary tools
go get -u golang.org/x/mobile/bind
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init

# Build PocketFHIR .aar for Android
echo "Building PocketFHIR .aar file for Android..."
gomobile bind -target=android -androidapi=21 -o pocketfhir.aar ./pocketfhir
if [ $? -ne 0 ]; then
echo "Android build failed!"
exit 1
fi
mv pocketfhir.aar ../fhir_ant/android/app/libs/pocketfhir.aar
rm pocketfhir-sources.jar

#!/bin/bash

cd ../fhir_ant

# Define the file path
FILE_PATH="./android/app/build.gradle"

# Use sed to replace the specified line
sed -i.bak "s/implementation(name: 'pocketfhir', ext: 'aar') \/\/ Include PocketFHIR \.aar/implementation(name: 'pocketfhir-2', ext: 'aar') \/\/ Include PocketFHIR \.aar/" "$FILE_PATH"

flutter clean ; flutter pub get ; flutter build apk

sed -i.bak "s/implementation(name: 'pocketfhir-2', ext: 'aar') \/\/ Include PocketFHIR \.aar/implementation(name: 'pocketfhir', ext: 'aar') \/\/ Include PocketFHIR \.aar/" "$FILE_PATH"

flutter clean ; flutter pub get ; flutter build apk

cd ../pocketfhir
52 changes: 52 additions & 0 deletions config/caddy/Caddyfile.fhirant
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Listen on port 8081 for HTTP requests
10.0.0.16:8081 {
# Set the root directory for serving files, such as certificates
root * /absolute/path/to/storage/pki/authorities/local

# Enable file server to serve static files like root.crt
handle_path /certs/* {
file_server browse
}

# Reverse proxy configuration for PocketBase
handle {
reverse_proxy 127.0.0.1:8090 {
transport http {
read_timeout 360s
}
}
}

# Logging setup
log {
output file /absolute/path/to/storage/caddy_debug.log {
roll_size 5MiB
roll_keep 10
roll_keep_for 720h
}
format json
}
}

# HTTPS server block for serving PocketBase via HTTPS
10.0.2.16:8443 {
# Enable TLS with automatic certificates (use internal certificates for testing)
tls internal

# Set up reverse proxy for HTTPS
reverse_proxy 127.0.0.1:8090 {
transport http {
read_timeout 360s
}
}

# Logging setup for HTTPS server
log {
output file /absolute/path/to/storage/caddy_https_debug.log {
roll_size 5MiB
roll_keep 10
roll_keep_for 720h
}
format json
}
}
212 changes: 212 additions & 0 deletions config/caddy/temp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
{
"logging": {
"logs": {
"default": {
"exclude": [
"http.log.access.log0",
"http.log.access.log1"
]
},
"log0": {
"writer": {
"filename": "/absolute/path/to/storage/caddy_debug.log",
"output": "file",
"roll_keep": 10,
"roll_keep_days": 30,
"roll_size_mb": 5
},
"encoder": {
"format": "json"
},
"include": [
"http.log.access.log0"
]
},
"log1": {
"writer": {
"filename": "/absolute/path/to/storage/caddy_https_debug.log",
"output": "file",
"roll_keep": 10,
"roll_keep_days": 30,
"roll_size_mb": 5
},
"encoder": {
"format": "json"
},
"include": [
"http.log.access.log1"
]
}
}
},
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":8081"
],
"routes": [
{
"match": [
{
"host": [
"10.0.0.16"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "vars",
"root": "/absolute/path/to/storage/pki/authorities/local"
}
]
},
{
"group": "group2",
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "rewrite",
"strip_path_prefix": "/certs"
}
]
},
{
"handle": [
{
"browse": {},
"handler": "file_server",
"hide": [
"./Caddyfile.fhirant"
]
}
]
}
]
}
],
"match": [
{
"path": [
"/certs/*"
]
}
]
},
{
"group": "group2",
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"transport": {
"protocol": "http",
"read_timeout": 360000000000
},
"upstreams": [
{
"dial": "127.0.0.1:8090"
}
]
}
]
}
]
}
]
}
]
}
],
"terminal": true
}
],
"logs": {
"logger_names": {
"10.0.0.16": [
"log0"
]
}
}
},
"srv1": {
"listen": [
":8443"
],
"routes": [
{
"match": [
{
"host": [
"10.0.2.16"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"transport": {
"protocol": "http",
"read_timeout": 360000000000
},
"upstreams": [
{
"dial": "127.0.0.1:8090"
}
]
}
]
}
]
}
],
"terminal": true
}
],
"logs": {
"logger_names": {
"10.0.2.16": [
"log1"
]
}
}
}
}
},
"tls": {
"automation": {
"policies": [
{
"subjects": [
"10.0.2.16"
],
"issuers": [
{
"module": "internal"
}
]
}
]
}
}
}
}
Loading

0 comments on commit 4eeda64

Please sign in to comment.