Skip to content
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
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM php:7-apache

# MAINTAINER Alexander Malic <[email protected]>
# MAINTAINER Vincent Emonet <[email protected]>
# MAINTAINER Michel Dumontier <[email protected]>

ARG APP_ENV=prod

WORKDIR /tmp

RUN apt-get update && apt-get install -y zip && \
a2enmod rewrite && \
a2enmod headers && \
echo "Header set Access-Control-Allow-Origin \"*\"" >> /etc/apache2/sites-available/000-default.conf && \
php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer


WORKDIR /var/www/html

COPY ./slim-server/SwaggerServer/ .

RUN composer install

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,19 @@ Code stub was generated with [Swagger CodeGen](https://github.com/swagger-api/sw
Modified the composer.json to include MonoLog and ElasticSearch libraries

Code currently in index.php file

## Deploy prefixcommons API

Use the start.sh scripts to deploy on node2 (will use `/data/prefixcommons` as working folder):

```bash
./start.sh
```

> It will create the required folders, start docker containers and init database

## Docker compose

Docker compose is not finished

The goal is to avoid needing to perform bash operations by preparing the httpd and elasticsearch images
33 changes: 33 additions & 0 deletions docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: "2"

networks:
net1: {}

services:
nginx-proxy:
image: jwilder/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
- net1

es:
build: ./prefixcommons-elasticsearch
expose:
- "9200"
- "9300"
environment:
WEB_PORTS: 9200
VIRTUAL_HOST: www.prefixcommonsx.org
networks:
- net1

webapp:
build: ./prefixcommons-httpd
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: www.prefixcommonsx.org
networks:
- net1
8 changes: 8 additions & 0 deletions docker-compose/prefixcommons-elasticsearch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM elasticsearch:latest

ADD ./config/elasticsearch.yml /usr/share/elasticsearch/config/elasticsearch.yml

CMD ["elasticsearch"]

EXPOSE 80
EXPOSE 9300
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please see the documentation for further information on configuration options:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: "elasticsearch-cors"
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: "node-1"
#
# Add custom attributes to the node:
#
# node.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
# path.data: /path/to/data
#
# Path to log files:
#
# path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
# bootstrap.mlockall: true
#
# Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory
# available on the system and that the owner of the process is allowed to use this limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
# network.host: 192.168.0.1
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 80
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
# discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
# discovery.zen.minimum_master_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
# gateway.recover_after_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>
#
# ---------------------------------- Various -----------------------------------
#
# Disable starting multiple nodes on a single system:
#
# node.max_local_storage_nodes: 1
#
# Require explicit names when deleting indices:
#
# action.destructive_requires_name: true

http.cors.enabled: true
http.cors.allow-origin: "*"
16 changes: 16 additions & 0 deletions docker-compose/prefixcommons-httpd/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM httpd

MAINTAINER Alexander Malic <[email protected]>

RUN apt-get update \
&& apt-get install -y git netcat curl \
&& cd /opt \
&& git clone https://github.com/amalic/webapp-es-ang.git \
&& cp -r ./webapp-es-ang/html/* /usr/local/apache2/htdocs/ \
&& git clone https://github.com/prefixcommons/data-ingest.git \
&& cd ./webapp-es-ang/es \
&& mv ../../data-ingest/json/lsregistry.json . \
&& while ! echo exit | netcat es 9200; do sleep 1; done \
&& curl -XDELETE http://es:9200/prefixcommons > /dev/null \
&& curl -XPUT http://es:9200/prefixcommons -d @mappings.json > /dev/null \
&& curl -XPUT http://es:9200/_bulk?pretty --data-binary @lsregistry.json > /dev/null
38 changes: 38 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
events {
worker_connections 1024;
}


http {
server {
listen 8080;
server_name elastic.prefixcommons.org;

rewrite ^/(.*) /$1 break;
proxy_ignore_client_abort on;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;

proxy_set_header Access-Control-Allow-Origin "*";

location ~ ^(/|/_aliases|.*/_search|.*/_mapping|/_cluster.*|/_status.*|/_nodes)$ {
limit_except GET POST OPTIONS {
deny all;
}
proxy_pass http://elasticsearch:9200;
proxy_pass_request_headers on;
}

location / {
# Auth: https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/
limit_except GET {
deny all;
}
auth_basic "Administrator’s Area";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://elasticsearch:9200;
proxy_pass_request_headers on;
}
}
}
Loading