Skip to content

Commit

Permalink
general improvement*
Browse files Browse the repository at this point in the history
  • Loading branch information
anatolicvs committed Feb 28, 2020
1 parent 4b0ac59 commit a87300e
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 28 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,8 @@ You can use OpenSSL to display the content of each PEM certificate:

Then ensure that the value matches the one in `elasticsearch.yml`.
For more complete information on a certificate:
`openssl x509 -in admin.pem -text -noout`
`openssl x509 -in admin.pem -text -noout`

### NOSPC: no space left on device' while running the nodeJS in docker

`sudo docker system prune -af`
37 changes: 37 additions & 0 deletions doc/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM node:latest

RUN apt-get update && \
apt-get install -y git \
openssh-server

RUN mkdir /var/run/sshd
EXPOSE 22

ARG SSH_KEY
ARG SSH_KEY_PASSPHRASE
RUN chmod go-w /root

RUN mkdir -p /root/.ssh && \
chmod 600 /root/.ssh

RUN echo "$SSH_KEY" >> /root/.ssh/id_rsa && \
echo "$SSH_KEY_PASSPHRASE" >> /root/.ssh/id_rsa.pub

RUN chmod -R 600 /root/.ssh/id_rsa && \
chmod -R 600 /root/.ssh/id_rsa.pub

RUN ssh-keyscan -Ht rsa forgemia.inra.fr,147.100.164.13 >> ~/.ssh/known_hosts

RUN mkdir /app/

WORKDIR /app/

RUN git clone [email protected]:magnus.anatolius/in-sylva.doc.git

RUN cd ./in-sylva.doc/website && yarn

EXPOSE 3000 35729

WORKDIR /app/in-sylva.doc/website/

CMD ["yarn", "start"]
Empty file added doc/build.sh
Empty file.
Empty file added doc/run.sh
Empty file.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ services:
REACT_APP_IN_SYLVA_KEYCLOAK_HOST: http://in-sylva.keycloak
REACT_APP_IN_SYLVA_KEYCLOAK_PORT: 7000
ports:
- 3000:4000
- 3000:3000
links:
- gatekeeper
- keycloak
Expand Down
5 changes: 0 additions & 5 deletions portal/.env
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
REACT_APP_IN_SYLVA_GATEKEEPER_HOST=/gatekeeper
REACT_APP_IN_SYLVA_GATEKEEPER_PORT=4000

REACT_APP_IN_SYLVA_SOURCE_MANAGER_HOST=/source-manager
REACT_APP_IN_SYLVA_SOURCE_MANAGER_PORT=5000

REACT_APP_IN_SYLVA_KEYCLOAK_HOST=/keycloak
REACT_APP_IN_SYLVA_KEYCLOAK_PORT=7000

REACT_APP_PORT=3000
2 changes: 1 addition & 1 deletion portal/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ while [ "$1" != "" ]; do
shift
done
# --no-cache
docker build --no-cache --build-arg SSH_KEY="$SSH_KEY" --build-arg SSH_KEY_PASSPHRASE="$SSH_KEY_PASSPHRASE" --tag in-sylva.portal .
docker build --build-arg SSH_KEY="$SSH_KEY" --build-arg SSH_KEY_PASSPHRASE="$SSH_KEY_PASSPHRASE" --tag in-sylva.portal .
7 changes: 7 additions & 0 deletions portal/env-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
window._env_ = {
REACT_APP_IN_SYLVA_GATEKEEPER_HOST: "/gatekeeper",
REACT_APP_IN_SYLVA_SOURCE_MANAGER_HOST: "/source-manager",
REACT_APP_IN_SYLVA_KEYCLOAK_HOST: "/keycloak",
REACT_APP_IN_SYLVA_KEYCLOAK_PORT: "7000",
REACT_APP_PORT: "3000",
}
3 changes: 1 addition & 2 deletions portal/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ server {
include /etc/nginx/mime.types;
listen 3000;
listen [::]:3000;
listen [::]:7000;
server_name _;

access_log /var/log/nginx/host.access.log;
Expand Down Expand Up @@ -49,7 +48,7 @@ server {

location /keycloak/auth/ {
proxy_pass http://backend_keycloak/keycloak/auth/;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
10 changes: 10 additions & 0 deletions search/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
REACT_APP_IN_SYLVA_GATEKEEPER_HOST=/gatekeeper
REACT_APP_IN_SYLVA_GATEKEEPER_PORT=4000

REACT_APP_IN_SYLVA_SOURCE_MANAGER_HOST=/source-manager
REACT_APP_IN_SYLVA_SOURCE_MANAGER_PORT=5000

REACT_APP_IN_SYLVA_KEYCLOAK_HOST=/keycloak
REACT_APP_IN_SYLVA_KEYCLOAK_PORT=7000

REACT_APP_PORT=3000
8 changes: 6 additions & 2 deletions search/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# build environment
FROM node:latest as portal
FROM node:latest as search

RUN apt-get update && \
apt-get install -y git \
Expand Down Expand Up @@ -41,12 +41,16 @@ RUN yarn build
# production environment
FROM nginx:latest

COPY --from=portal /app/in-sylva.search.app/build /usr/share/nginx/html
COPY --from=search /app/in-sylva.search.app/build /usr/share/nginx/html

RUN rm /etc/nginx/conf.d/default.conf

COPY nginx/nginx.conf /etc/nginx/conf.d

WORKDIR /usr/share/nginx/html
COPY ./env.sh .
COPY .env .

EXPOSE 3000

CMD ["nginx", "-g", "daemon off;"]
3 changes: 2 additions & 1 deletion search/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ while [ "$1" != "" ]; do
shift
done

docker build --no-cache --build-arg SSH_KEY="$SSH_KEY" --build-arg SSH_KEY_PASSPHRASE="$SSH_KEY_PASSPHRASE" --tag in-sylva.search .
# --no-cache
docker build --build-arg SSH_KEY="$SSH_KEY" --build-arg SSH_KEY_PASSPHRASE="$SSH_KEY_PASSPHRASE" --tag in-sylva.search .

29 changes: 29 additions & 0 deletions search/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Recreate config file
rm -rf ./env-config.js
touch ./env-config.js

# Add assignment
echo "window._env_ = {" >> ./env-config.js

# Read each line in .env file
# Each line represents key=value pairs
while read -r line || [[ -n "$line" ]];
do
# Split env variables by character `=`
if printf '%s\n' "$line" | grep -q -e '='; then
varname=$(printf '%s\n' "$line" | sed -e 's/=.*//')
varvalue=$(printf '%s\n' "$line" | sed -e 's/^[^=]*=//')
fi

# Read value of current variable if exists as Environment variable
value=$(printf '%s\n' "${!varname}")
# Otherwise use value from .env file
[[ -z $value ]] && value=${varvalue}

# Append configuration property to JS file
echo " $varname: \"$value\"," >> ./env-config.js
done < .env

echo "}" >> ./env-config.js
105 changes: 90 additions & 15 deletions search/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,27 +1,102 @@
server {

resolver 127.0.0.1 [::];

upstream backend_gatekeeper {
server gatekeeper:4000;
}

upstream backend_keycloak {
server keycloak:7000;
}

upstream backend_source_manager {
server source-manager:5000;
}

server {
include /etc/nginx/mime.types;
listen 3000;
listen 4000;
listen 5000;
listen 7000;
listen [::]:3000;
server_name _;

access_log /var/log/nginx/host.access.log;
error_log /var/log/nginx/host.error.log;

root /usr/share/nginx/html;
index index.html index.htm;

location /gatekeeper/ {
proxy_pass http://backend_gatekeeper/;

proxy_set_header Host $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;
}

location /keycloak/ {
proxy_pass http://backend_keycloak/;

proxy_set_header Host $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-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /keycloak/auth/ {
proxy_pass http://backend_keycloak/keycloak/auth/;

proxy_set_header Host $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-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /source-manager/ {
proxy_pass http://backend_source_manager/;

proxy_set_header Host $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;
}

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
proxy_http_version 1.1;
proxy_set_header upgrade $http_upgrade;
proxy_set_header connection keep-alive;
proxy_set_header host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-forwarded-proto $scheme;
root /usr/share/nginx/html;
index index.html;
autoindex on;
set $fallback_file /index.html;
if ($http_accept !~ text/html) {
set $fallback_file /null;
}
if ($uri ~ /$) {
set $fallback_file /null;
}
try_files $uri $fallback_file;

if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin: $http_origin');
add_header 'Access-Control-Allow-Origin: GET, POST, DELETE, PUT, PATCH, OPTIONS');
add_header 'Access-Control-Allow-Credentials: true');
add_header 'Vary: Origin');

}

add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
}

error_page 500 502 503 504 /50x.html;

location = /50x.html {
root /usr/share/nginx/html;
}

}

0 comments on commit a87300e

Please sign in to comment.