Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge Dev into master #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
TBCLIENT=dafne-it
TBCLIENT=dafne-it
COMPOSE_FORCE_WINDOWS_HOST=1
75 changes: 55 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,82 @@ Let's startup every client with a single command

## Must have

### chocolatey
### Chocolatey

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

### Packages

choco install -y docker
choco install -y docker-machine
choco install -y docker-machine-vmwareworkstation
choco install -y docker
choco install -y docker-machine
choco install -y docker-machine-vmwareworkstation

## Steps that must be automated

### Set ENV

Once you specify the environemtn from start.bat, that value must flow until docker-compose env file and replace both the names of nginx and node hostname and the folder they munt for the plugins, lucklily they have all the same name!
Once you specify the environment from setup.bat, that value must flow until docker-compose env file and replace both the names of nginx and node hostname and the folder they munt for the plugins, lucklily they have all the same name! but we have to rewrite it several times.

### Shared folder

Once you create your VM default, you must stop it, go to the VM vmx file and edit it manually by replacing those lines:

sharedFolder0.present = "true"
sharedFolder0.enabled = "true"
sharedFolder0.readAccess = "true"
sharedFolder0.writeAccess = "true"
sharedFolder0.hostPath = "C:\Users\"
sharedFolder0.guestName = "Users"
sharedFolder0.expiration = "never"
sharedFolder.maxNum = "1"

With those:

### first time
sharedFolder0.present = "true"
sharedFolder0.enabled = "true"
sharedFolder0.readAccess = "true"
sharedFolder0.writeAccess = "true"
sharedFolder0.hostPath = "C:\Users\"
sharedFolder0.guestName = "Users"
sharedFolder0.expiration = "never"
sharedFolder1.present = "true"
sharedFolder1.enabled = "true"
sharedFolder1.readAccess = "true"
sharedFolder1.writeAccess = "true"
sharedFolder1.hostPath = "DRIVE:\PATH\TO\ROOT\OF\ALL\YOUR\PROJECTS"
sharedFolder1.guestName = "TB"
sharedFolder1.expiration = "never"
sharedFolder.maxNum = "2"

docker-machine create -d vmwareworkstation default
## Usage from Windows

docker-machine start | iex
Just launch `start.bat` from PowerShell and follow the instructions, if is a new client or a new installation it will take a while to clone, make npm install and build all the projects.

### everyday
## Debugging

docker-machine start
### SSH into VM

docker-machine start | iex
As I find Bash if much more powerful than batch or PowerShell, I suggesto opening a connection to the VM running the real containers, both to check if the mounted volume is there and to get informations about ip addresses or container statuses.

## Usage
docker-machine active
docker machine inspect default

### Linux
From here you can get the IP of the virtual machine we just setup (default is byu convention, if you use a different VM just replace it with your VM name)
Now log-in into the VM with Putty/Kitty/.. with the credentials and the IP you can get from the docker-machine inspection

start.sh
### Containers

docker-compose rm --all && docker-compose pull && docker-compose build --no-cache && docker-compose up -d --force-recreate
Now you can check the processes with one of the following commands

### Windows
ps aux
docker ps

start.bat
If you see your containers running you should be able to run commands on them. I.e. if you want to check the mounted partitions just dive a bit from here:

docker-compose rm --all ; docker-compose pull ; docker-compose build --no-cache ; docker-compose up -d --force-recreate
docker exec node ls -lah /mnt/
docker exec node ls -lah /home/node/app

### Default
# TODO

docker-compose up
* Fix docker-compose volume definition from hardcoded to env dependant
* start.sh need a python file to create the proper crm.dev.json file
11 changes: 3 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
version: '3.0'
version: '3.3'
services:
proxy:
build: ./nginx/
hostname: ${TBCLIENT:-dafne-it}
domainname: ${TBCLIENT:-dafne-it}.dev
ports:
- 80:80
container_name: proxy
Expand All @@ -13,20 +12,16 @@ services:
- node
volumes:
- crm
dns:
- 8.8.8.8
- 8.8.4.4
app:
image: node:carbon
container_name: app
volumes:
- .:/app
- crm:/app
- /mnt/hgfs/A/experiments/fromwin/:/home/node/app
- crm:/home/node/app

node:
build: ./node/
hostname: ${TBCLIENT:-dafne-it}.node
domainname: ${TBCLIENT:-dafne-it}.node.dev
container_name: node
depends_on:
- app
Expand Down
8 changes: 2 additions & 6 deletions node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
FROM node:carbon

# Create app directory
WORKDIR /app/node-api

RUN npm install -g gulp gulp-cli pm2

CMD [ "npm", "run", "dev" ]
ADD start.sh /home/node/start.sh
ADD config.json /home/node/config.json
20 changes: 20 additions & 0 deletions node/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"paths": {
"site": "..\\crm-40\\out\\debug",
"modules": "..\\crm-40-modules\\out\\debug",
"config": "..\\TBCLIENT\\config",
"plugins": "..\\TBCLIENT\\out\\debug",
"attachments": "..\\attachments",
"versions": "..\\versions"
},
"database": {
"domain": null,
"user": "sa",
"password": "Telemaco1",
"server": "192.168.101.39\\SQL2K1201",
"port": 1433,
"database": "DICOFARM_IT_DEVTBCRM",
"connectionTimeout": 10000,
"requestTimeout": 60000
}
}
6 changes: 0 additions & 6 deletions node/paths.txt

This file was deleted.

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

dev="/home/node/app/node-api/crm.dev.json"
if [ -f "$file" ]
then
echo "$dev found."
else
echo "Generating $dev"
cp /home/node/app/node-api/crm.json /home/node/app/node-api/crm.dev.json
fi

cd /home/node/app/dafne-it && nohup build watch &
cd /home/node/app/crm-40 && nohup npm run watch &
cd /home/node/app/crm-40-modules && nohup npm run watch &
cd /home/node/app/node-api && npm run dev

# awk -F, 'NR==FNR{a[$1]=$0;next;}a[$1]{$0=a[$1]}1' /home/node/paths /home/node/app/node-api/crm.dev.json
91 changes: 49 additions & 42 deletions setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,78 +7,85 @@ set /p CODE="client code (DEFAULT: dafne-it ...):"
IF NOT DEFINED CODE SET CODE="dafne-it"
IF %CODE%=="" SET CODE="dafne-it"

IF NOT DEFINED DRIVE SET DRIVE=%CD%
IF %DRIVE%=="" SET DRIVE=%CD%
IF NOT DEFINED DRIVE SET DRIVE=%~d0
IF %DRIVE%=="" SET DRIVE=%~d0

IF NOT DEFINED DIR SET DIR=%~p0
IF %DIR%=="" SET DIR=%~p0
echo %DRIVE%%DIR%
IF NOT EXIST %DRIVE%%DIR% GOTO NOWINDIR

IF NOT EXIST %DRIVE%:\%DIR% GOTO NOWINDIR

echo /%DRIVE% %DIR%
%DRIVE%:
echo %DRIVE%%DIR%
%DRIVE%
cd %DIR%

IF NOT EXIST %DRIVE%:\%DIR%\attachments mkdir attachments
IF NOT EXIST %DRIVE%:\%DIR%\versions mkdir versions
IF NOT EXIST %DRIVE%%DIR%\attachments mkdir attachments
IF NOT EXIST %DRIVE%%DIR%\versions mkdir versions

IF NOT EXIST %DRIVE%:\%DIR%\crm-40 (
IF NOT EXIST %DRIVE%%DIR%\crm-40 (
echo "Cloning crm-40"
git clone http://devlab.trueblue.it/tbcrm-40/crm-40.git
echo "Installing and building crm-40"
start /separate /wait cmd /c "git pull && npm install && npm run build" &
) ELSE (
echo "OK crm-40"
)

IF NOT EXIST %DRIVE%:\%DIR%\node-api (
IF NOT EXIST %DRIVE%%DIR%\node-api (
echo "Cloning node-api"
git clone http://devlab.trueblue.it/tbcrm-40/node-api.git
echo "Installing node-api"
start /separate /wait cmd /c "git pull && npm install" &
) ELSE (
echo "OK node-api"
)

IF NOT EXIST %DRIVE%:\%DIR%\crm-40-modules (
IF NOT EXIST %DRIVE%%DIR%\crm-40-modules (
echo "Cloning crm-40-modules"
git clone http://devlab.trueblue.it/tbcrm-40/crm-40-modules.git
echo "Installing and building crm-40-modules"
start /separate /wait cmd /c "git pull && npm install && npm run build" &
) ELSE (
echo "OK modules"
)

IF NOT EXIST %DRIVE%:\%DIR%\%CODE% (
echo "Cloning plugins"
IF NOT EXIST %DRIVE%%DIR%\%CODE% (
echo "Cloning and building plugins"
git clone http://devlab.trueblue.it/tbcrm-40/%CODE%.git
echo "Installing and building plugins"
start /separate /wait cmd /c "git pull && npm install && build build" &
) ELSE (
echo "OK plugins"
)

docker-machine --native-ssh create -d vmwareworkstation default
:: we need that check working
:: docker-machine ls | find /i "default"
::IF %ERRORLEVEL% NEQ 0 (
:: here I suggest making a link to the .docker folder pointing to a different hard disk, to avoid fill C: with shit
docker-machine --native-ssh create -d vmwareworkstation default
:: sorry I have not time to fix vmx file for every docker version
:: you have shut it down, edit A:\docker\machine\machines\default\default.vmx
:: sharedFolder0.present = "true"
:: sharedFolder0.enabled = "true"
:: sharedFolder0.readAccess = "true"
:: sharedFolder0.writeAccess = "true"
:: sharedFolder0.hostPath = "C:\Users\"
:: sharedFolder0.guestName = "Users"
:: sharedFolder0.expiration = "never"
:: sharedFolder1.present = "true"
:: sharedFolder1.enabled = "true"
:: sharedFolder1.readAccess = "true"
:: sharedFolder1.writeAccess = "true"
:: sharedFolder1.hostPath = "A:\"
:: sharedFolder1.guestName = "TB"
:: sharedFolder1.expiration = "never"
:: sharedFolder.maxNum = "2"
:: )
docker-machine start
docker-machine env | iex



call nvm install 8.9.4
call nvm use 8.9.4
start /separate /wait cmd /c "git pull && npm install -g gulp gulp-cli" &

cd crm-40
echo "install and build CRM 40"
start /separate /wait cmd /c "git pull && npm install && npm run build" &
cd ..

cd crm-40-modules
echo "install and build modules"
start /separate /wait cmd /c "git pull && npm install && npm run build" &
cd ..

cd %CODE%
echo "install and build plugin"
start /separate /wait cmd /c "git pull && npm install && npm run build" &
cd ..

cd node-api
echo "install and run API"
start /separate /wait cmd /c "git pull && npm install && npm run dev" &
cd ..

FOR /f "tokens=*" %%i IN ('docker-machine env default') DO %%i
:: docker-machine env | iex
:: docker-compose rm --all && docker-compose pull &&
docker-compose build --no-cache
docker-compose up

:NOWINDIR
6 changes: 3 additions & 3 deletions start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ IF NOT EXIST %DRIVE%%DIR%\%CODE% (
echo "OK plugins"
)

call nvm install 8.9.3
call nvm use 8.9.3
start /separate /wait cmd /c "git pull && npm install -g gulp gulp-cli" &
call nvm install 8.9.4
call nvm use 8.9.4
start /separate /wait cmd /c "npm install -g gulp gulp-cli" &

cd crm-40
echo "install and build CRM 40"
Expand Down