Skip to content

Commit

Permalink
Migrate to unpriviledged nginx image to work also on restricted envir…
Browse files Browse the repository at this point in the history
…onments

Add docker-compose spec
  • Loading branch information
mmelko committed May 16, 2022
1 parent da10fec commit 52ae58e
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 17 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ COPY . .

RUN yarn run build

FROM nginx:latest
FROM nginxinc/nginx-unprivileged

COPY --from=appbuild /app/dist/* /usr/share/nginx/html/
COPY nginx/start_nginx.sh .
COPY nginx/nginx.conf /etc/nginx/nginx.conf

EXPOSE 80
EXPOSE 8080

HEALTHCHECK --interval=3s --start-period=10s CMD curl --fail http://localhost/ || exit 1

CMD ["./start_nginx.sh"]
CMD ["nginx", "-g", "daemon off;"]
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
kaoto-backend-svc:
image: kaotoio/backend:nightly
ports:
- 8081:8081
web:
build: .
ports:
- 8080:8080
depends_on:
- kaoto-backend-svc
60 changes: 60 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

worker_processes auto;

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


events {
worker_connections 1024;
}


http {
proxy_temp_path /tmp/proxy_temp;
client_body_temp_path /tmp/client_temp;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
scgi_temp_path /tmp/scgi_temp;

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;

keepalive_timeout 65;

#gzip on;

server {
listen 8080;
server_name $http_host;

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

location /api/ {
proxy_set_header Host $host;
proxy_pass http://kaoto-backend-svc:8081/;
}

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}


error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

}

}
11 changes: 0 additions & 11 deletions nginx/start_nginx.sh

This file was deleted.

7 changes: 5 additions & 2 deletions src/api/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ export interface IFetch {
}
declare var window: any;
let apiURL = process.env.KAOTO_API;
// console.log(process.env.NODE_ENV);

if (process.env.NODE_ENV == 'production' && window.KAOTO_API) {
if (process.env.NODE_ENV == 'production') {
if (window.KAOTO_API) {
apiURL = window.KAOTO_API;
} else {
apiURL = '/api'
}
}

// converts an object into a query string
Expand Down

0 comments on commit 52ae58e

Please sign in to comment.