<commit_before># hiShop - e-commerce

[![Travis Widget]][Travis] [![Coverage Status Widget]][Coverage Status] [![Download Bintray Widget]][Download Bintray] [![Download Docker Widget]][Download Docker]

[Travis]: https://travis-ci.org/NBakaev/hishop
[Travis Widget]: https://travis-ci.org/NBakaev/hishop.svg?branch=master
[Coverage Status]: https://codecov.io/github/NBakaev/hishop?branch=master
[Download Docker]: https://hub.docker.com/r/nbakaev/hishop-api-backend/
[Coverage Status Widget]: https://img.shields.io/codecov/c/github/NBakaev/hishop/master.svg
[Download Bintray]: https://bintray.com/nbakaev/maven/hishop/_latestVersion
[Download Bintray Widget]: https://api.bintray.com/packages/nbakaev/maven/hishop/images/download.svg
[Download Docker Widget]: https://img.shields.io/docker/pulls/nbakaev/hishop-api-backend.svg

## Build & run  
This project uses Java & Spring Boot.
To start server use `mvn package & java -jar target/ru.nbakaev.hishop.jar`.

### Notes for compiling
 - After compiling - test will be automatically run. You can skip tests on packaging step with `mvn package -DskipTests`
 - After executing `mvn package` - file `target/ru.nbakaev.hishop.jar` will be created. This is fat jar - fully executable jar file with embedded tomcat (provided by spring boot). So, you don't need anything dependencies, such as tomcat etc. You only need installed java to run program. 
 - In CI environment variables with API keys are set up to use in tests. But if you want to run tests locally, you must set up Mandatory options.

## Start options
Web server startup port is described in `application.properties`. You can override it in environment or VM options on startup

### Mandatory options
`NOTE:` You must pass to application API keys of services to start application:

  - MongoDB (database)
  - mailgun credentials (send email messages with DKIM and spam filter)
   
For example
```bash
java -jar target/ru.nbakaev.hishop.jar \
    --spring_data_mongodb_uri="mongodb://H7sXKfNiJOoBPByF:X5hQ8Kx9KQZ9165.mongolab.com:39165/hishop" \
    --mailgun_api_key="key-b305ee369ffb69e8b559" \
    --mailgun_url="https://api.mailgun.net/v3/sandbox21473e1b5f33c2e779eb7a46.mailgun.org/messages" \
    --spring.output.ansi.enabled=ALWAYS
```

Example above use command-line arguments to java program. You can use the same thing with environment variables:
```bash
#!/usr/bin/env bash
export spring_data_mongodb_uri="mongodb://H7sXKfNiJOoBPByF:X5hQ8Kx9KQZ9165.mongolab.com:39165/hishop"
export mailgun_api_key="key-b305ee369ffb69e8b559"
export mailgun_url="https://api.mailgun.net/v3/sandbox21473e1b5f33c2e779eb7a46.mailgun.org/messages"
export spring.output.ansi.enabled=ALWAYS

java -jar target/ru.nbakaev.hishop.jar
````

Use any method that is more preferred to you or combine them.

### Docker

```bash
docker run -d \
    -e  "spring_data_mongodb_uri=mongodb://H7sXKfNiJOoBPByF:X5hQ8Kx9KQZ9165.mongolab.com:39165/hishop" \
    -e mailgun_api_key="key-b305ee369ffb69e8b559" \
    -e "mailgun_url=https://api.mailgun.net/v3/sandbox21473e1b5f3344c2950ac2e779eb7a46.mailgun.org/messages" \
    -e spring.output.ansi.enabled=ALWAYS \
    --name hishop1 nbakaev/hishop-api-backend:0.2.2-RELEASE_build.127763392
```

Docker notes:

 - you can not pass `--name hishop1`. This is unic container name. Instead container id will used provided. 
 - you can replace `nbakaev/hishop-api-backend:0.2.2-RELEASE_build.127763392` to another version. All [version are here on docker hub](https://hub.docker.com/r/nbakaev/hishop-api-backend/tags/)

#### Program arguments

 - `--spring.output.ansi.enabled=ALWAYS` to enable color logging
 - `-Dhttp.proxyHost=127.0.0.1
 -Dhttp.proxyPort=9999
 -Dhttps.proxyHost=127.0.0.1
 -Dhttps.proxyPort=9999
 -Djava.net.useSystemProxies=true
` - just common argument to use local proxy for JVM (port 9999)

##### Profiles
 - `--spring.profiles.active=production` - by default; start with remote MongoDB database
 - `--spring.profiles.active=development` - start with embedded(running on local machine; fully clean on every startup) MongoDB database. Used primary for tests.

## Components:

### Backend:
 - Java 8
 - Spring 4 & Spring Boot 1.3
 - MongoDB 3 (NoSQL database)
<commit_msg>docker map port to host notes<commit_after># hiShop - e-commerce

[![Travis Widget]][Travis] [![Coverage Status Widget]][Coverage Status] [![Download Bintray Widget]][Download Bintray] [![Download Docker Widget]][Download Docker]

[Travis]: https://travis-ci.org/NBakaev/hishop
[Travis Widget]: https://travis-ci.org/NBakaev/hishop.svg?branch=master
[Coverage Status]: https://codecov.io/github/NBakaev/hishop?branch=master
[Download Docker]: https://hub.docker.com/r/nbakaev/hishop-api-backend/
[Coverage Status Widget]: https://img.shields.io/codecov/c/github/NBakaev/hishop/master.svg
[Download Bintray]: https://bintray.com/nbakaev/maven/hishop/_latestVersion
[Download Bintray Widget]: https://api.bintray.com/packages/nbakaev/maven/hishop/images/download.svg
[Download Docker Widget]: https://img.shields.io/docker/pulls/nbakaev/hishop-api-backend.svg

## Build & run  
This project uses Java & Spring Boot.
To start server use `mvn package & java -jar target/ru.nbakaev.hishop.jar`.

### Notes for compiling
 - After compiling - test will be automatically run. You can skip tests on packaging step with `mvn package -DskipTests`
 - After executing `mvn package` - file `target/ru.nbakaev.hishop.jar` will be created. This is fat jar - fully executable jar file with embedded tomcat (provided by spring boot). So, you don't need anything dependencies, such as tomcat etc. You only need installed java to run program. 
 - In CI environment variables with API keys are set up to use in tests. But if you want to run tests locally, you must set up Mandatory options.

## Start options
Web server startup port is described in `application.properties`. You can override it in environment or VM options on startup

### Mandatory options
`NOTE:` You must pass to application API keys of services to start application:

  - MongoDB (database)
  - mailgun credentials (send email messages with DKIM and spam filter)
   
For example
```bash
java -jar target/ru.nbakaev.hishop.jar \
    --spring_data_mongodb_uri="mongodb://H7sXKfNiJOoBPByF:X5hQ8Kx9KQZ9165.mongolab.com:39165/hishop" \
    --mailgun_api_key="key-b305ee369ffb69e8b559" \
    --mailgun_url="https://api.mailgun.net/v3/sandbox21473e1b5f33c2e779eb7a46.mailgun.org/messages" \
    --spring.output.ansi.enabled=ALWAYS
```

Example above use command-line arguments to java program. You can use the same thing with environment variables:
```bash
#!/usr/bin/env bash
export spring_data_mongodb_uri="mongodb://H7sXKfNiJOoBPByF:X5hQ8Kx9KQZ9165.mongolab.com:39165/hishop"
export mailgun_api_key="key-b305ee369ffb69e8b559"
export mailgun_url="https://api.mailgun.net/v3/sandbox21473e1b5f33c2e779eb7a46.mailgun.org/messages"
export spring.output.ansi.enabled=ALWAYS

java -jar target/ru.nbakaev.hishop.jar
````

Use any method that is more preferred to you or combine them.

### Docker

```bash
docker run -d -p 5555:5555 \
    -e  "spring_data_mongodb_uri=mongodb://H7sXKfNiJOoBPByF:X5hQ8Kx9KQZ9165.mongolab.com:39165/hishop" \
    -e mailgun_api_key="key-b305ee369ffb69e8b559" \
    -e "mailgun_url=https://api.mailgun.net/v3/sandbox21473e1b5f3344c2950ac2e779eb7a46.mailgun.org/messages" \
    -e spring.output.ansi.enabled=ALWAYS \
    --name hishop1 nbakaev/hishop-api-backend:0.2.2-RELEASE_build.127763392
```

Docker notes:

 - you can not pass `--name hishop1`. This is unic container name. Instead container id will used provided. 
 - you can replace `nbakaev/hishop-api-backend:0.2.2-RELEASE_build.127763392` to another version. All [version are here on docker hub](https://hub.docker.com/r/nbakaev/hishop-api-backend/tags/)
 - `-p 5555:5555` by default docker create fully independent network environment with ports that are not hosts (see linux [cgroups](https://en.wikipedia.org/wiki/Cgroups)). 
`-p 5555:5555` option map container port 5555 to host than make available service outside.

#### Program arguments

 - `--spring.output.ansi.enabled=ALWAYS` to enable color logging
 - `-Dhttp.proxyHost=127.0.0.1
 -Dhttp.proxyPort=9999
 -Dhttps.proxyHost=127.0.0.1
 -Dhttps.proxyPort=9999
 -Djava.net.useSystemProxies=true
` - just common argument to use local proxy for JVM (port 9999)

##### Profiles
 - `--spring.profiles.active=production` - by default; start with remote MongoDB database
 - `--spring.profiles.active=development` - start with embedded(running on local machine; fully clean on every startup) MongoDB database. Used primary for tests.

## Components:

### Backend:
 - Java 8
 - Spring 4 & Spring Boot 1.3
 - MongoDB 3 (NoSQL database)

{'fraction_non_alphanumeric': 0.11643364657345863, 'fraction_numerical': 0.046069218427687374, 'mean_word_length': 4.502522068095838, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 25, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2028601', 'n_tokens_mistral': 3282, 'n_tokens_neox': 2969, 'n_words': 768}