Skip to content

Commit

Permalink
[Upd] Add Docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope committed May 13, 2022
1 parent f6e623e commit e1d80ab
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 8 deletions.
5 changes: 1 addition & 4 deletions .docker/config.js.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// Dynamic configuration
window.__config__ = {
APP_DOMAIN: '${API_DOMAIN}',
APP_TITLE: '${APP_TITLE}',
LANGUAGE: '${LANGUAGE}',
NAVIGATOR_LANGUAGE: '${NAVIGATOR_LANGUAGE}'
REACT_APP_DOMAIN: '${REACT_APP_DOMAIN}'
}
2 changes: 1 addition & 1 deletion .docker/docker-entrypoint.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh
set -eu

envsubst '${API_URL} ${APP_TITLE} ${LANGUAGE} ${NAVIGATOR_LANGUAGE} ${BASENAME}' < /etc/nginx/config.js.template > /var/www/config.js
envsubst '${REACT_APP_DOMAIN}' < /etc/nginx/config.js.template > /var/www/config.js

exec "$@"
35 changes: 35 additions & 0 deletions .docker/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
<!--# echo var="status" default="" --> <!--# echo var="status_text" default="Something goes wrong" -->
| SGoV Data Management
</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--# if expr="$status = 502" -->
<meta http-equiv="refresh" content="2">
<!--# endif -->
</head>
<style type="text/css">
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: #fff;
height: 100vh;
margin: 0;
background: #263238 linear-gradient(5deg, #057fa5 0%, #263238 100%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style>
<body>
<!--# if expr="$status = 502" -->
<h1>We are updating our website </h1>
<p>This is only for a few seconds, you will be redirected.</p>
<!--# else -->
<h1><!--# echo var="status" default="" --> <!--# echo var="status_text" default="Something goes wrong" --></h1>
<!--# endif -->
</body>
</html>
49 changes: 49 additions & 0 deletions .docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {

include mime.types;
default_type application/octet-stream;

map $status $status_text {
400 'Bad Request';
401 'Unauthorized';
403 'Forbidden';
404 'Not Found';
405 'Method Not Allowed';
406 'Not Acceptable';
413 'Payload Too Large';
414 'URI Too Long';
431 'Request Header Fields Too Large';
500 'Internal Server Error';
501 'Not Implemented';
502 'Bad Gateway';
503 'Service Unavailable';
504 'Gateway Timeout';
}

server {
listen 80;
server_name localhost;

error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
415 416 417 418 421 422 423 424 426 428 429 431 451 500 501 502 503
504 505 506 507 508 510 511 /error.html;

location = /error.html {
ssi on;
internal;
root /usr/share/nginx/html;
}

location / {
root /var/www;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
}
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@ FROM nginx:1.17.0-alpine
# Copy the react build from Build Stage
COPY --from=build /usr/src/app/build /var/www

# Copy error page
COPY .docker/error.html /usr/share/nginx/html

# Copy our custom nginx config
COPY .docker/config.js.template /etc/nginx/config.js.template
COPY .docker/nginx.conf /etc/nginx/nginx.conf

COPY --from=build /usr/src/app/build /usr/share/nginx/html
# Copy our custom nginx config
COPY .docker/config.js.template /etc/nginx/config.js.template

# from the outside.
EXPOSE 80

COPY .docker/docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
CMD ["nginx", "-g", "daemon off;"]

12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3"
services:
plan-manager:
build:
context: .
dockerfile: Dockerfile
image: plan-manager:latest
container_name: plan-manager
ports:
- "8080:80"
environment:
- REACT_APP_DOMAIN=http://localhost:8080/csat
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!-- Runtime environment variables -->
<script src="%PUBLIC_URL%/config.js"></script>
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand Down

0 comments on commit e1d80ab

Please sign in to comment.