# Deploy Ecolyo-Agent back-office

This app is deployed on an Openshift cluster provided by Synaaps, all instructions for authentification and deployment are given [here](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-server/-/blob/dev/k8s/README.md)

## CICD

This app has a gitlab CI/CD pipeline you can find in the .gitlab-ci.yml file.
On the dev branch and on merge requests, the pipeline will run a build stage and a quality stage.
On dev and master branches, the pipeline will run a docker image build that you can find in the GitLab container registry.


## Alpha usage

In order to test the app on alpha you can do the following steps:

- Build locally your docker image for the client and/or the server

```sh
docker build . -t registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-<server/client>:your-tag
```

- Push the image

```sh
docker push registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-<server/client>:your-tag
```

- Connect to alpha in ssh, go to ecolyo-agent > docker-compose.yml and change the image tag for client and/or server

- Then launch the app, it will pull automatically the new images

```sh
docker-compose up -d
```

- If you have access denied issue, try to docker login

```sh
docker login registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/
```

- If you want to update alpha using the same image tag with edited image, just pull manually your new image and rebuild the concerned image

```sh
docker pull registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-<server/client>:your-tag

docker-compose up -d
```

If you need to work with prices on alpha, you will need to init the prices database.

- First get the mysql container id

```sh
docker ps
```

- Then get into the container

```sh
docker exec -it <container-id> bash
```

- Then execute the mysql script that imports all the prices in DB

```sh
mysql --local-infile=1 -uroot -p backoffice < /dbinit/dbinit.sql
```

You will be prompted for the admin password, use the db password set in the .env file.

Now you're ready to edit your prices on alpha !