Skip to content

Commit 10a8211

Browse files
authored
Merge pull request #23 from CodeChillAlluna/develop
Develop
2 parents d9ea4f7 + cf2704e commit 10a8211

47 files changed

Lines changed: 1891 additions & 214 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Whitespace-only changes.

README.md

Lines changed: 24 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# Code & Chill
2+
[![Server version](https://img.shields.io/github/tag/CodeChillAlluna/code-chill-server.svg?label=version&style=for-the-badge)](https://github.com/CodeChillAlluna/code-chill-server)
23
[![Travis (.org) branch](https://img.shields.io/travis/CodeChillAlluna/code-chill-server/master.svg?style=for-the-badge)](https://travis-ci.org/CodeChillAlluna/code-chill-server)
3-
[![Codacy branch
4-
grade](https://img.shields.io/codacy/grade/35fabe502d4341cc9096e5e63812f348/master.svg?style=for-the-badge)](https://app.codacy.com/project/Lulu300/code-chill-server/dashboard)
5-
[![Coveralls github
6-
branch](https://img.shields.io/coveralls/github/CodeChillAlluna/code-chill-server/master.svg?style=for-the-badge)](https://coveralls.io/github/CodeChillAlluna/code-chill-server)
7-
[![Code
8-
Climate](https://img.shields.io/codeclimate/maintainability/CodeChillAlluna/code-chill-server.svg?style=for-the-badge)](https://codeclimate.com/github/CodeChillAlluna/code-chill-server)
4+
[![Codacy branch grade](https://img.shields.io/codacy/grade/35fabe502d4341cc9096e5e63812f348/master.svg?style=for-the-badge)](https://app.codacy.com/project/Lulu300/code-chill-server/dashboard)
5+
[![Coveralls github branch](https://img.shields.io/coveralls/github/CodeChillAlluna/code-chill-server/master.svg?style=for-the-badge)](https://coveralls.io/github/CodeChillAlluna/code-chill-server)
6+
[![Code Climate](https://img.shields.io/codeclimate/maintainability/CodeChillAlluna/code-chill-server.svg?style=for-the-badge)](https://codeclimate.com/github/CodeChillAlluna/code-chill-server)
97
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge)](https://opensource.org/licenses/Apache-2.0)
108

119
Master project : Online development environment
@@ -21,8 +19,8 @@ This repository contains the server part of the project, if you want to check th
2119

2220
## Summary
2321

24-
- Installation for contributing to this project (click [here](#development-environment))
25-
- Installation of the application (click [here](#installation))
22+
- [Installation for contributing to this project](#development-environment)
23+
- [Installation of the application](#installation)
2624

2725

2826

@@ -76,14 +74,15 @@ To start or building the application or execute tests, you need to access the VM
7674
vagrant ssh
7775
```
7876

79-
Before starting the application don't forget to start the server. If you have not installed it yet click [here](https://github.com/CodeChillAlluna/code-chill-server).
8077

8178

82-
83-
#### Start the application
79+
#### Start the API
8480

8581
```sh
8682
mvn spring-boot:run
83+
84+
# You can also use our custom script to clean docker container before start
85+
./server run
8786
```
8887

8988
Then you can request : http://localhost:8080 to view use the API.
@@ -93,130 +92,35 @@ Then you can request : http://localhost:8080 to view use the API.
9392
#### Execute tests
9493

9594
```sh
96-
mvn test -DforkCount=0
95+
mvn test
96+
97+
# You can also use our custom script to clean docker container before start
98+
./server test
9799
```
98100

99101

100102

101103
#### Build the application
102104

103105
```sh
104-
mvn clean package -DforkCount=0
105-
```
106-
107-
108-
109-
## Installation
106+
mvn clean package
110107

111-
Here is the setup to installing the production environment if you want to use this project.
112-
113-
### Requirements
114-
115-
- [Docker](https://www.docker.com/)
116-
- [Docker Compose](https://docs.docker.com/compose/)
117-
118-
119-
120-
### Configure & Start application
121-
122-
Create a file named `application.yml` wherever you want and change the values you need.
123-
124-
```javascript
125-
# config context path to "/" by setting an empty string
126-
server:
127-
contextPath:
128-
129-
130-
spring:
131-
# Spring profile
132-
profiles: "prod"
133-
# JACKSON
134-
jackson:
135-
serialization:
136-
INDENT_OUTPUT: true
137-
mail:
138-
host:
139-
port: 587
140-
username: "CHANGEME"
141-
password: "CHANGEME"
142-
smtp:
143-
protocol: smtp
144-
debug: true
145-
properties.mail.smtp:
146-
auth: true
147-
starttls.enable: true
148-
149-
datasource:
150-
url: jdbc:postgresql://code-chill-db/codechill
151-
username: code
152-
password: chill
153-
154-
jpa:
155-
generate:
156-
ddl: true
157-
hibernate:
158-
ddl-auto: update
159-
160-
jwt:
161-
header: Authorization
162-
secret: mySecret
163-
expiration: 604800
164-
route:
165-
authentication:
166-
path: auth
167-
refresh: refresh
168-
169-
logging:
170-
file: /var/log/codechill-server.log
171-
pattern:
172-
file: "%d %-5level [%thread] %logger : %msg%n"
173-
level:
174-
ROOT: ERROR
175-
176-
app:
177-
# URL of the docker API to use for client environment
178-
dockerurl: http://localhost:2375
179-
# URL of the server where Code&Chill is installed
180-
clienturl: http://localhost:3000
181-
# Range of port to use for user environment
182-
minPort: 64000
183-
maxPort: 64050
108+
# You can also use our custom script to clean docker container before start
109+
./server package
184110
```
185111

186112

187113

188-
Then create a file named `docker-compose.yml` wherever you want.
189-
190-
```yaml
191-
version: "3.3"
192-
193-
services:
194-
code-chill-server:
195-
# You can use any version of our image
196-
image: codechillaluna/code-chill-server:latest
197-
volumes:
198-
# Change "$HOME/config" by the folder where your application.yml is.
199-
- $HOME/config:/config/
200-
ports:
201-
# Change the first value to the port you want to use on your host.
202-
- "8080:8080"
203-
depends_on:
204-
- code-chill-db
205-
code-chill-db:
206-
image: postgres:10.5-alpine
207-
environment:
208-
# Change postgres credentials and database name.
209-
POSTGRES_PASSWORD: chill
210-
POSTGRES_USER: code
211-
POSTGRES_DB: codechill
114+
#### Format your code
115+
116+
```sh
117+
mvn fmt:format
212118
```
213119

120+
Remember to format your code before commit, otherwise your build will fail.
214121

215122

216-
Now you just have to go on the folder where your `docker-compose.yml` is and execute this command to start Code&Chill Server :
217123

218-
```sh
219-
docker-compose up
220-
```
124+
## Installation
221125

222-
Now you can install [Code&Chill Client](https://github.com/CodeChillAlluna/code-chill-client#installation) and start coding on Code&Chill !
126+
The procedure to install Code&Chill is accessible in our main [repository](https://github.com/CodeChillAlluna/code-chill#installation).

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.0
1+
1.6.0

docker/DockerFile

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,35 @@ FROM alpine:latest
22

33
RUN apk update && apk upgrade && \
44
apk add nginx && \
5-
apk add openjdk8-jre && \
65
apk add openrc && \
76
rm -rf /var/cache/apk/* && \
87
mkdir -p /run/nginx
98

9+
ENV JAVA_HOME /opt/openjdk-12
10+
ENV PATH $JAVA_HOME/bin:$PATH
11+
12+
# https://jdk.java.net/
13+
ENV JAVA_VERSION 12-ea+29
14+
ENV JAVA_URL https://download.java.net/java/early_access/alpine/29/binaries/openjdk-12-ea+29_linux-x64-musl_bin.tar.gz
15+
ENV JAVA_SHA256 39c22481736ae8a054fc820ad0cc3f1d9ad3f3f00d8111775573fe6d04c18bf5
16+
# "For Alpine Linux, builds are produced on a reduced schedule and may not be in sync with the other platforms."
17+
18+
RUN set -eux; \
19+
\
20+
wget -O /openjdk.tgz "$JAVA_URL"; \
21+
echo "$JAVA_SHA256 */openjdk.tgz" | sha256sum -c -; \
22+
mkdir -p "$JAVA_HOME"; \
23+
tar --extract --file /openjdk.tgz --directory "$JAVA_HOME" --strip-components 1; \
24+
rm /openjdk.tgz; \
25+
\
26+
# https://github.com/docker-library/openjdk/issues/212#issuecomment-420979840
27+
# https://openjdk.java.net/jeps/341
28+
java -Xshare:dump; \
29+
\
30+
# basic smoke test
31+
java --version; \
32+
javac --version
33+
1034
RUN mkdir /www
1135
RUN mkdir /config
1236

@@ -16,6 +40,6 @@ COPY codechill-server.jar /www/
1640

1741
RUN rc-update add nginx default
1842

19-
EXPOSE 80 443
43+
EXPOSE 80 443 8080
2044

21-
CMD ["/usr/bin/java", "-jar", "-Dspring.profiles.active=prod", "-Dspring.config.location=/config/application.yml", "/www/codechill-server.jar"]
45+
CMD ["java", "-jar", "-Dspring.profiles.active=prod", "-Dspring.config.location=/config/application.yml", "/www/codechill-server.jar"]

docker/config/application.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ server:
66
spring:
77
#Spring profile
88
profiles: "prod"
9+
mvc.async.request-timeout: -1
910
# JACKSON
1011
jackson:
1112
serialization:

install/deploy.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ docker_build=$docker_path/codechill-server.jar
55

66
build_app () {
77
# Build the app
8-
mvn clean package -DforkCount=0
8+
mvn clean package -DskipTests=true
99
}
1010

1111
build_dockerfile() {
@@ -23,12 +23,14 @@ deploy() {
2323
echo $TRAVIS_BRANCH
2424
if [ "$TRAVIS_BRANCH" == "master" ]
2525
then
26+
echo "Master"
2627
VERSION=`cat VERSION`
2728
docker tag codechillaluna/code-chill-server codechillaluna/code-chill-server:latest
2829
docker push codechillaluna/code-chill-server:latest
2930
else
30-
echo "else"
31+
echo "Other branch"
3132
VERSION=$TRAVIS_BRANCH
33+
echo $VERSION
3234
fi
3335
docker tag codechillaluna/code-chill-server codechillaluna/code-chill-server:$VERSION
3436
docker push codechillaluna/code-chill-server:$VERSION

install/install.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,12 @@ setup () {
135135
# Install git
136136
sudo apt-get install -y git
137137

138+
sudo apt install dos2unix
139+
138140
# Install jdk
139141
sudo echo oracle-java11-installer shared/accepted-oracle-license-v1-2 select true | sudo /usr/bin/debconf-set-selections
140142
sudo add-apt-repository ppa:linuxuprising/java -y
143+
sudo apt-get update -y
141144
sudo apt-get install -y oracle-java11-installer
142145
sudo apt-get install -y oracle-java11-set-default
143146

pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@
119119
<version>2.1.0.RELEASE</version>
120120
</dependency>
121121

122+
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
123+
<dependency>
124+
<groupId>commons-io</groupId>
125+
<artifactId>commons-io</artifactId>
126+
<version>2.6</version>
127+
</dependency>
128+
129+
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
130+
<dependency>
131+
<groupId>org.apache.httpcomponents</groupId>
132+
<artifactId>httpclient</artifactId>
133+
<version>4.5.6</version>
134+
</dependency>
135+
122136
</dependencies>
123137

124138
<build>

server.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
clean_docker() {
4+
docker stop $(docker ps -a -q)
5+
docker rm $(docker ps -a -q)
6+
}
7+
8+
format_code() {
9+
mvn fmt:format
10+
}
11+
12+
run_server() {
13+
clean_docker
14+
format_code
15+
mvn spring-boot:run
16+
}
17+
18+
run_test() {
19+
clean_docker
20+
format_code
21+
mvn test
22+
}
23+
24+
package() {
25+
clean_docker
26+
format_code
27+
mvn clean package
28+
}
29+
30+
if [ "$1" == "run" ]
31+
then
32+
run_server
33+
elif [ "$1" == "test" ]
34+
then
35+
run_test
36+
elif [ "$1" == "package" ]
37+
then
38+
package
39+
elif [ "$1" == "format" ]
40+
then
41+
format_code
42+
else
43+
echo -e 'Wrong arg, Usage :\n1) run (Run the server)\n2) test (Run all tests)\n3) package (Make a jar)\n4) format (format code)'
44+
fi

src/main/java/fr/codechill/spring/config/WebSecurityConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ protected void configure(HttpSecurity httpSecurity) throws Exception {
6767
.antMatchers(
6868
HttpMethod.GET,
6969
"/",
70+
"/containers/**",
71+
"/images/**",
7072
"/*.html",
7173
"/favicon.ico",
7274
"/**/*.html",

0 commit comments

Comments
 (0)