Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OZ-668: Setup Dockerfiles needed to build Ozone Embedded Docker images #1

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
307 changes: 32 additions & 275 deletions docker/docker-compose-embedded.yaml.template

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docker/eip-erpnext-openmrs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM mekomsolutions/eip-client
ADD target/ozone-1.0.0-SNAPSHOT/distro/binaries/eip-erpnext-openmrs /eip-client/routes
ADD binaries/eip-erpnext-openmrs /eip-client/routes
2 changes: 1 addition & 1 deletion docker/eip-odoo-openmrs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM mekomsolutions/eip-client
ADD target/ozone-1.0.0-SNAPSHOT/distro/binaries/eip-odoo-openmrs /eip-client/routes
ADD binaries/eip-odoo-openmrs /eip-client/routes
2 changes: 1 addition & 1 deletion docker/eip-openmrs-senaite/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM mekomsolutions/eip-client
ADD target/ozone-1.0.0-SNAPSHOT/distro/binaries/eip-openmrs-senaite /eip-client/routes
ADD binaries/eip-openmrs-senaite /eip-client/routes
4 changes: 2 additions & 2 deletions docker/erpnext/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM frappe/erpnext:v15.12.2
ADD target/ozone-1.0.0-SNAPSHOT/distro/binaries/erpnext/scripts /opt/erpnext/scripts
ADD target/ozone-1.0.0-SNAPSHOT/distro/configs/erpnext/initializer_config /opt/erpnext/configs
ADD binaries/erpnext/scripts /opt/erpnext/scripts
ADD configs/erpnext/initializer_config /opt/erpnext/configs
8 changes: 8 additions & 0 deletions docker/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM openmrs/openmrs-reference-application-3-frontend:nightly
ADD distro/binaries/openmrs/frontend /usr/share/nginx/html
ADD distro/configs/openmrs/frontend_config /usr/share/nginx/html/ozone
RUN mkdir -p /app
WORKDIR /app
COPY docker-embedded/frontend/startup.sh /app
RUN chmod +x /app/startup.sh
CMD ["/app/startup.sh"]
6 changes: 6 additions & 0 deletions docker/frontend/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
set -e
if [ -f "/usr/share/nginx/html/ozone/ozone-frontend-config.json" ]; then
envsubst '${ODOO_PUBLIC_URL} ${OPENMRS_PUBLIC_URL} ${SENAITE_PUBLIC_URL}' < "/usr/share/nginx/html/ozone/ozone-frontend-config.json" | sponge "/usr/share/nginx/html/ozone/ozone-frontend-config.json"
fi
/usr/local/bin/startup.sh
5 changes: 5 additions & 0 deletions docker/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM mariadb:10.8
ADD data/mysql/create_db.sh /docker-entrypoint-initdb.d/create_db.sh
ADD data/mysql/eip-odoo-openmrs /docker-entrypoint-initdb.d/db/eip-odoo-openmrs
ADD data/mysql/openmrs /docker-entrypoint-initdb.d/db/openmrs
ADD data/mysql/eip-openmrs-senaite /docker-entrypoint-initdb.d/db/eip-openmrs-senaite
3 changes: 3 additions & 0 deletions docker/postgresql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM postgres:13
ADD data/postgresql/create_db.sh /docker-entrypoint-initdb.d/create_db.sh
ADD data/postgresql/odoo /docker-entrypoint-initdb.d/db/odoo
6 changes: 6 additions & 0 deletions docker/proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM nginx:1.25-alpine

ENV FRAME_ANCESTORS ""

COPY docker-embedded/proxy/nginx.conf /etc/nginx/nginx.conf
COPY docker-embedded/proxy/default.conf.template /etc/nginx/templates/
153 changes: 153 additions & 0 deletions docker/proxy/default.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
map $request_uri $csp_header {
default "default-src 'self' 'unsafe-inline' 'unsafe-eval'; base-uri 'self'; font-src 'self'; img-src 'self' data:; frame-ancestors 'self' ${FRAME_ANCESTORS};";
"~^/openmrs/(?:admin|dictionary|module|patientDashboard.form)/" "default-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; base-uri 'self'; font-src 'self'; frame-ancestors 'self';";
"~^/openmrs/owa" "default-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; base-uri 'self'; font-src 'self' data:; img-src 'self' data:; frame-ancestors 'self';";
}

map $http_x_forwarded_proto $forwarded_proto {
"~.*" $http_x_forwarded_proto;
default $scheme;
}

map $http_x_real_ip $forwarded_ip {
"~.*" $http_x_real_ip;
default $remote_addr;
}

map $forwarded_proto $var_proxy_cookie_flags {
https "JSESSIONID secure samesite=strict";
default "off";
}

upstream frontend {
# always assume the frontend will be available
server frontend max_fails=0;
}

upstream backend {
server openmrs:8080 max_fails=0;
}

server {
listen 80;

add_header X-XSS-Protection "1; mode=block";
add_header Content-Security-Policy $csp_header;
add_header X-Content-Type-Options nosniff;

proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $forwarded_proto;
proxy_set_header X-Real-IP $forwarded_ip;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# if serving this via HTTPS, the following is recommended
# proxy_cookie_flags $var_proxy_cookie_flags;
proxy_http_version 1.1;

gzip on;
gzip_vary on;
# 1 KiB
gzip_min_length 1024;
gzip_proxied any;
gzip_http_version 1.0;
gzip_types font/eot
font/otf
font/ttf
image/svg+xml
text/css
text/javascript
text/plain
text/xml
application/atom+xml
application/geo+json
application/importmap+json
application/javascript
application/x-javascript
application/json
application/ld+json
application/fhir+json
application/fhir+xml
application/manifest+json
application/rdf+xml
application/rss+xml
application/xhtml+xml
application/xml;

# all redirects are relative to the gateway
absolute_redirect off;

location = /openmrs/spa {
return 301 /openmrs/spa/;
}

location /openmrs/spa/ {
proxy_pass http://frontend/;
proxy_redirect http://$host/ /openmrs/spa/;
}

location /openmrs {
proxy_pass http://backend;
}

location = / {
return 301 /openmrs/spa/;
}
}

server {
listen 8069;
server_name localhost;

# Increase proxy buffer size
proxy_buffers 16 64k;
proxy_buffer_size 128k;
# Force timeouts if the backend dies
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
# Enable data compression
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain text/xml text/css text/less application/x-javascript application/xml application/json application/javascript;
gzip_vary on;

# Proxy header and settings
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;



# Cache static data
location ~* /web/static/ {
proxy_cache_valid 200 60m;
proxy_buffering on;
expires 864000;
set $odoo odoo:8069;
proxy_pass http://$odoo;
}

location / {

set $odoo odoo:8069;
proxy_pass http://$odoo;
# The following makes the timeout broader
proxy_read_timeout 30000;
proxy_redirect off;
}

location /longpolling {
set $odoo odoo:8072;
proxy_pass http://$odoo;
}
}

server {
listen 8081;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
set $senaite senaite:8080;
proxy_pass http://$senaite;
}
}
31 changes: 31 additions & 0 deletions docker/proxy/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
user nobody;
worker_processes auto;

error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;

keepalive_timeout 65;
resolver 127.0.0.11;

include /etc/nginx/conf.d/*.conf;
}
2 changes: 1 addition & 1 deletion docker/senaite/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM mekomsolutions/senaite
ADD target/ozone-1.0.0-SNAPSHOT/distro/configs/senaite/initializer_config /data/importdata/senaite
ADD configs/senaite/initializer_config /data/importdata/senaite
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
${project.build.directory}/${project.artifactId}-${project.version}</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}</directory>
<directory>${project.basedir}/docker</directory>
<includes>
<include>docker/</include>
<include>**</include>
</includes>
<excludes>
<exclude>scripts/distro/</exclude>
Expand Down