Merge branch 'feat/manager_deploy' of git.happy-dev.fr:startinblox/applications/sib-app into project-integration-manager

This commit is contained in:
Jean-Baptiste Pasquier 2019-12-02 14:04:28 +01:00
commit 33e2278ffb
No known key found for this signature in database
GPG Key ID: F2702E6D22ED4D62
31 changed files with 1374 additions and 1632 deletions

14
.gitignore vendored
View File

@ -1,9 +1,5 @@
/node_modules
/src/config.json
/www/index.html
/www/index.*.html
/www/styles/
/www/scripts/
/www/lib/
/www/oidc-client-config.json
*.iml
**/node_modules
**/config.json
*.iml
*.swp
dist

19
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,19 @@
image: node
stages:
- deploy
deploy_staging:
stage: deploy
environment: staging
script:
- echo "$APP_CONFIG" > config.json
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' > gitlab.key && chmod 600 gitlab.key
- npm install
- npm run build
- scp -i gitlab.key -o StrictHostKeyChecking=no -r dist/* test-paris@ssh-test-paris.happy-dev.fr:~/staging/www/
only:
- feat/manager_deploy
- staging
tags:
- sib

View File

@ -1,86 +0,0 @@
DIST_DIR := www
SCRIPT_SRC := $(wildcard src/scripts/*.js)
SCRIPT_DEST := $(SCRIPT_SRC:src/%=$(DIST_DIR)/%)
default: build
build: $(DIST_DIR)/index.html $(DIST_DIR)/styles/index.css $(SCRIPT_DEST)
watch:
@echo 'watching for change'
@echo 'press Ctrl+C to stop'
@while true; do \
$(MAKE) --silent build; \
sleep 0.5; \
done
# pug
$(DIST_DIR)/index.html: src/index.pug src/config.json $(wildcard src/*.pug src/*/*.pug)
@echo pug: $< ➜ $@
@export ENV="dev"; \
node_modules/.bin/pug --pretty $< --out $(dir $@) -O src/config.json || touch $@
# pug (alpha)
$(DIST_DIR)/index.alpha.html: src/index.pug src/config.json $(wildcard src/*.pug src/*/*.pug)
@echo pug: $< ➜ $@
@export ENV="alpha"; \
node_modules/.bin/pug --pretty $< --out $(dir $@) -E alpha.html -O src/config.json || touch $@
# pug (paris)
$(DIST_DIR)/index.paris.html: src/index.pug src/config.json $(wildcard src/*.pug src/*/*.pug)
@echo pug: $< ➜ $@
@export ENV="paris"; \
node_modules/.bin/pug --pretty $< --out $(dir $@) -E paris.html -O src/config.json || touch $@
# pug (nantes)
$(DIST_DIR)/index.nantes.html: src/index.pug src/config.json $(wildcard src/*.pug src/*/*.pug)
@echo pug: $< ➜ $@
@export ENV="nantes"; \
node_modules/.bin/pug --pretty $< --out $(dir $@) -E nantes.html -O src/config.json || touch $@
# sass
$(DIST_DIR)/styles/index.css: src/styles/_index.scss $(wildcard src/*.scss src/*/*.scss src/*/*/*.scss src/*/*/*/*.scss)
@echo sass: $< ➜ $@
@node_modules/.bin/node-sass $< $@ --source-map true --source-map-contents || touch $@
# babel
$(DIST_DIR)/%.js: src/%.js .babelrc
@echo babel: $< ➜ $@
@mkdir -p $(dir $@)
@node_modules/.bin/babel $< --out-file $@ --source-maps || touch $@
buildparis: build
$(MAKE) $(DIST_DIR)/index.paris.html
syncparis: buildparis
rsync -rv --exclude '*.html' www/* test-paris@ssh-test-paris.happy-dev.fr:~/www/
rsync --no-R --no-implied-dirs www/index.paris.html test-paris@ssh-test-paris.happy-dev.fr:~/www/index.html
rsync -v www/.htaccess test-paris@ssh-test-paris.happy-dev.fr:~/www/
buildnantes: build
$(MAKE) $(DIST_DIR)/index.nantes.html
syncnantes: buildnantes
rsync -rv --exclude '*.html' www/* test-nantes@ssh-test-nantes.happy-dev.fr:~/www/
rsync --no-R --no-implied-dirs www/index.nantes.html test-nantes@ssh-test-nantes.happy-dev.fr:~/www/index.html
rsync -v www/.htaccess test-nantes@ssh-test-nantes.happy-dev.fr:~/www/
buildalpha: build
$(MAKE) $(DIST_DIR)/index.alpha.html
syncalpha: buildalpha
rsync -rv --exclude '*.html' www/* alpha@ssh-alpha.happy-dev.fr:~/www/
rsync --no-R --no-implied-dirs www/index.alpha.html alpha@ssh-alpha.happy-dev.fr:~/www/index.html
rsync -v www/.htaccess alpha@ssh-alpha.happy-dev.fr:~/www/
sync: syncnantes syncparis
syncprod: syncalpha
.PHONY: default build watch sync syncprod

162
README.md
View File

@ -8,80 +8,36 @@ These instructions will get you a copy of the project up and running on your loc
### Prerequisites
To install SiB App, you'll need to have:
To install SiB App, you'll need:
- Python3 & Pip
- NodeJS & NPM
- A Prosody Server
- (Optional) A SMTP Server
* A SIB server with the appropriate modules
* A Prosody Server (with [appropriate modules](https://git.happy-dev.fr/startinblox/prosody/custom-prosody-modules/)
* A SMTP Server (optional)
* NodeJS on your machine
### Installing
Before diving in you have to check your SIB server supports the following LDP packages:
#### At first, you'll need to deploy a `sib-manager` server, then configure it.
* djangoldp_project: 0.1.12
* djangoldp_uploader: 0.0.5
* djangoldp_circle: 0.1.9
* djangoldp_notification: 0.1.4
* djangoldp_account: 0.2.12
* djangoldp_skill: 0.1.1
* djangoldp_joboffer: 0.1.1
* djangoldp_conversation: 0.2.1
* djangoldp_profile: 0.1.4
* djangoldp_invoice: 0.1.0
* oidc_provider: 'git+https://github.com/jblemee/django-oidc-provider.git@develop'
#### `sib-manager` installation or update
Those packages are given with the last stable version tested.
```
$ pip3 install -U sib-manager
```
Refer to the [documentation to install a SIB server](https://git.happy-dev.fr/startinblox/devops/doc/wikis/y_a_sib_application) with this configuration.
#### `sib-manager` deploy
## Configure your SIB server
```
$ sib startproject newserver -m djangoldp_project -m oidc_provider@django-oidc-provider -m djangoldp_circle -m djangoldp_joboffer -m djangoldp_profile -m djangoldp_skill -m djangoldp_account -m djangoldp_notification -m djangoldp_conversation
$ sib initproject newserver
```
Create a Client ID for Prosody & Client
We're using
- `djangoldp_project`,
- `django-oidc-provider`,
- `djangoldp_circle`,
- `djangoldp_joboffer`,
- `djangoldp_profile`,
- `djangoldp_skill`,
- `djangoldp_account`,
- `djangoldp_notification`,
- `djangoldp_conversation`
As dependencies, if you don't want them, just remove the `-m packagename`.
`sibserver` is the name of the folder that `sib-manager` will create, choose it wisely.
In addition to the `startproject` you can add :
- `--site-url "http://localhost:8000"`
- `--production` to use postgresql instead of sqlite
- `--db-host`, `--db-name`, `--db-user` and `--db-pass` are used to configure the database (mandatory with `--production`)
- `--smtp-host`, `--smtp-user` and `--smtp-pass` are used to configure the SMTP (optional)
#### `sibserver` configuration
You'll have to change some settings on the `sibserver` files.
- Add your server name to `ALLOWED_HOSTS`
- In `settings.py`, add your hostname on `ALLOWED_HOSTS`, eg:
```
ALLOWED_HOSTS = ['api.myserver.com', 'localhost']
```
- Around line `96-97` of `settings.py` set your `PROSODY_HTTP_URL`, `JABBER_DEFAULT_HOST`, eg:
```
PROSODY_HTTP_URL = 'https://jabber.happy-dev.fr'
JABBER_DEFAULT_HOST = 'happy-dev.fr'
```
#### `sib-manager` launching
On the first `sibserver` folder
```
$ ./manage.py runserver
```
#### Create a Client ID for Prosody & Client
- Go to `localhost:8000/admin/`
- Login with previously created account.
- If needed you can create another admin account with `./manage.py createsuperadmin`
- Login on `localhost:8000/admin/` with the admin account you configured
- Add a `Clients` on `OpenID Connect Provider` section
- Name it as you wish
- `Client type`: `Public`
@ -96,74 +52,38 @@ $ ./manage.py runserver
```
- Keep the `6-digits` newly create `Client ID` somewhere
#### Then, you'll have to install the client.
## Build the application
#### Clone this repository
In order to find your server(s) the client application needs to be assembled with the proper configuration.
Get the code of the SIB app on your machine:
```
# With SSH
$ git clone git@git.happy-dev.fr:startinblox/applications/sib-app.git
# Or with HTTPS
$ git clone https://git.happy-dev.fr/startinblox/applications/sib-app.git
$ git clone ...
```
#### Install dependencies
Then create a `config.json` with all the the capabilities the SIB App requires. Which are:
* businessproviders
* circles
* groups
* joboffers
* projects
* skills
* users
[The documentation](https://git.happy-dev.fr/startinblox/devops/doc/wikis/create_sib_application) explains the details of this file but for convienence a `config.sample.json` exists in the source.
Then build your new SIB App:
```
$ cd sib-app
$ npm install
$ npm run build
```
#### Configure `config.json`
On the newly created `./src/config.json` change the `dev` configuration like this:
```
"dev": {
"sdn": "http://api.myserver.com", # Or localhost:8000
"cdn": "https://cdn.happy-dev.fr",
"xmpp": "https://prosody.myserver.com/http-bind/",
"client_id": "000000" # <- Here goes your previously created Client ID
},
```
#### That's all! Now let's run it!
```
# For dev
$ make watch
$ npm run serve
# Or for prod
$ make build
# Then publish the www folder
```
## Deployment
Deployment will need a registered RSA Key on production servers.
### On Alpha
```
$ make syncprod
```
### On Staging
```
$ make sync
```
The application bundle is in the `dist` folder, ready to be deployed everywhere as a static file.
## Built With
* [Sib-Core](https://git.happy-dev.fr/startinblox/framework/sib-core/) - An awesome new framework!
### Architecture
Some general schema of the existing StartinBlox applications architecture can be found [here](https://docs.google.com/presentation/d/1iCRGaJpFvZjhjIUnpsn6lRTJJ31ES6n94BNkJygzUwM/edit?usp=sharing).
<!---
## Contributing
@ -178,4 +98,4 @@ We may add a `LICENSE.md`
* Maybe some thanks too
* Inspiration
* etc
--->
--->

View File

@ -1 +0,0 @@
node_modules/normalize.css/normalize.css

2614
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,18 +3,28 @@
"version": "1.0.0",
"license": "MIT",
"scripts": {
"serve": "node server.js",
"postinstall": "node postinstall.js"
},
"devDependencies": {
"@babel/core": "^7.4.4",
"@babel/cli": "^7.4.4",
"node-sass": "^4.12.0",
"pug-cli": "^1.0.0-alpha6",
"express": "^4.16.4"
"build": "run-p copy:* build:*",
"build:css": "node-sass ./src/styles/_index.scss dist/styles/index.css",
"build:js": "babel 'src/scripts/*.js' -o dist/scripts/index.js",
"build:html": "pug src/index.pug -o dist/ --obj config.json",
"copy:font": "copyfiles -f src/fonts/* dist/fonts",
"copy:image": "copyfiles -f src/images/* dist/images",
"serve": "serve -l 3000 dist/",
"watch": "run-p copy:* watch:* serve",
"watch:css": "node-sass --watch ./src/styles/_index.scss dist/styles/index.css",
"watch:js": "babel --watch 'src/scripts/*.js' -o dist/scripts/index.js",
"watch:pug": "pug --watch src/index.pug -o dist/ --obj config.json"
},
"dependencies": {
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.0",
"copyfiles": "^2.1.1",
"include-media": "^1.4.9",
"normalize.css": "^8.0.1"
"node-sass": "^4.13.0",
"normalize.css": "^8.0.1",
"npm-run-all": "^4.1.5",
"pug": "^2.0.4",
"pug-cli": "^1.0.0-alpha6",
"serve": "^11.2.0"
}
}

View File

@ -1,8 +0,0 @@
const fs = require('fs');
const { exec } = require('child_process');
if (!fs.existsSync('src/config.json')) {
const cmd = `rsync -ru src/config.sample.json src/config.json`;
console.log(cmd);
exec(cmd);
}

View File

@ -1,11 +0,0 @@
const port = 3000;
const distPath = 'www';
// express server
const { join } = require('path');
const express = require('express');
const app = express();
app
.use(express.static(distPath))
.get(/^[^.]*$/, (req, rep) => rep.sendFile(join(__dirname, distPath, '/index.html')))
.listen(port);

View File

@ -1,5 +1,5 @@
{
"dev": {
"development": {
"cdn": "https://cdn.happy-dev.fr",
"xmpp": "https://jabber.happy-dev.fr/http-bind/",
"authority": "http://127.0.0.1:8000/openid/",
@ -13,54 +13,5 @@
"skills": "http://127.0.0.1:8000/skills/",
"users": "http://127.0.0.1:8000/users/"
}
},
"alpha": {
"cdn": "https://cdn.happy-dev.fr",
"xmpp": "https://jabber.happy-dev.fr/http-bind/",
"authority": "https://api.alpha.happy-dev.fr/openid/",
"clientName": "SIB App",
"endpoints": {
"businessproviders": "https://api.alpha.happy-dev.fr/businessproviders/",
"circles": "https://api.alpha.happy-dev.fr/circles/",
"groups": "https://api.alpha.happy-dev.fr/groups/",
"joboffers": "https://api.alpha.happy-dev.fr/job-offers/",
"projects": "https://api.alpha.happy-dev.fr/projects/",
"skills": "https://api.alpha.happy-dev.fr/skills/",
"users": "https://api.alpha.happy-dev.fr/users/"
}
},
"paris": {
"sdn": "https://api.test-paris.happy-dev.fr",
"cdn": "https://cdn.happy-dev.fr",
"xmpp": "https://jabber.happy-dev.fr/http-bind/",
"authority": "https://api.test-paris.happy-dev.fr/openid/",
"clientName": "SIB App",
"endpoints": {
"businessproviders": "https://api.test-paris.happy-dev.fr/businessproviders/",
"circles": "https://api.test-paris.happy-dev.fr/circles/",
"groups": "https://api.test-paris.happy-dev.fr/groups/",
"joboffers": "https://api.test-paris.happy-dev.fr/job-offers/",
"projects": "https://api.test-paris.happy-dev.fr/projects/",
"skills": "https://api.test-paris.happy-dev.fr/skills/",
"users": "https://api.test-paris.happy-dev.fr/users/"
}
},
"nantes": {
"cdn": "https://cdn.happy-dev.fr",
"xmpp": "https://jabber.happy-dev.fr/http-bind/",
"authority": "https://api.test-nantes.happy-dev.fr/openid/",
"clientName": "SIB App",
"endpoints": {
"businessproviders": "https://api.test-nantes.happy-dev.fr/businessproviders/",
"circles": "https://api.test-nantes.happy-dev.fr/circles/",
"groups": "https://api.test-nantes.happy-dev.fr/groups/",
"joboffers": "https://api.test-nantes.happy-dev.fr/job-offers/",
"projects": "https://api.test-nantes.happy-dev.fr/projects/",
"skills": "https://api.test-nantes.happy-dev.fr/skills/",
"users": "https://api.test-nantes.happy-dev.fr/users/"
}
}
}
}

View File

Before

Width:  |  Height:  |  Size: 146 KiB

After

Width:  |  Height:  |  Size: 146 KiB

View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 111 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 559 B

After

Width:  |  Height:  |  Size: 559 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 583 B

After

Width:  |  Height:  |  Size: 583 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -1,8 +0,0 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule \. - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>