-
Notifications
You must be signed in to change notification settings - Fork 100
dev: ajout de donfiguration docker pour développer sans rien installe… #94
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
Open
benfonty
wants to merge
2
commits into
etalab:master
Choose a base branch
from
benfonty:misc/user-containers-for-development
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,5 @@ node_modules | |
| .env | ||
|
|
||
| db/data | ||
|
|
||
| docker-compose/.env | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,4 +157,4 @@ def add_header(r): | |
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| app.run() | ||
| app.run(debug = True, host='0.0.0.0') | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| POSTGRES_PASSWORD=<password> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Développer en local sans installer quoi que ce soit | ||
|
|
||
| Le seul prérequis est d'avoir docker et docker-compose installé sur votre machine. | ||
|
|
||
| le script `restart.sh` va démarrer trois containers: | ||
| - une instance de base de données | ||
| - Une serveur python | ||
| - Un client nodejs | ||
|
|
||
| Ces trois containers vont monter le répertoire de développement en volume. | ||
| Toutes les modifications effectuées dans le répertoire sont visibles directement dans les trois serveurs de dev. | ||
|
|
||
| ## Configuration | ||
|
|
||
| ### Configuration de la base de données | ||
|
|
||
| Il faut copier le fichier `./docker-compose/.env.sample` vers `./docker-compose/.env` et renseigner le mot de passe d'accès à la base de données. | ||
|
|
||
| ### Configuration du serveur | ||
|
|
||
| le fichier de donfiguration `./config.csv` doit être renseigné comme suit: | ||
|
|
||
| ``` | ||
| postgres | ||
| <mot de passe base de données> | ||
| postgres | ||
| dvf_202004 | ||
|
|
||
| ``` | ||
|
|
||
| ### Configuration du client | ||
|
|
||
| Le fichier `./.env` doit être configuré comme suit: | ||
|
|
||
| ``` | ||
| API_URL=http://server:5000/api | ||
| PORT=3000 | ||
|
|
||
| ``` | ||
|
|
||
| ## Alimentation de la base de données | ||
|
|
||
| La commande executée pour alimenter la base de données nécessite d'être lancée depuis ce serveur. | ||
|
|
||
| Voici les étapes: | ||
|
|
||
| - `docker exec -it postgres bash` | ||
| - `cd /home/dvfapp` | ||
|
|
||
| A partir de ce moment là on se trouve dans le container de base de données au niveau du répertoire des sources et la suite ne change pas. | ||
|
|
||
| - `cd db` | ||
| - `./build_db.sh` | ||
|
|
||
| **Attention**: Le batch `build_db.sh` ne va pas fonctionner si le serveur est connecté à la base de données. Pour éviter celà, quittez la webapp sur vos browsers, redémarrez l'ensemble (`restart.sh`) et lancez le script. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| version: '3' | ||
| services: | ||
| postgres: | ||
| build: ./postgres | ||
| image: dvfapp-postgres:latest | ||
| container_name: postgres | ||
| environment: | ||
| - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
| volumes: | ||
| - ./data:/var/lib/postgresql/data | ||
| - ../:/home/dvfapp | ||
| server: | ||
| build: ./server | ||
| image: dvfapp-server:latest | ||
| container_name: server | ||
| volumes: | ||
| - ../:/home/dvfapp | ||
| links: | ||
| - postgres | ||
| webapp: | ||
| build: ./webapp | ||
| image: dfvapp-webapp:latest | ||
| container_name: webapp | ||
| volumes: | ||
| - ../:/home/dvfapp | ||
| links: | ||
| - server | ||
| ports: | ||
| - 3000:3000 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| FROM postgres:13.0 | ||
|
|
||
| RUN \ | ||
| apt update && \ | ||
| # see https://github.com/debuerreotype/docker-debian-artifacts/issues/46 | ||
| touch /usr/share/man/man1/sh.distrib.1.gz && \ | ||
| apt upgrade -yy -q && \ | ||
| apt install -y wget sudo curl | ||
|
|
||
| RUN curl -sL https://deb.nodesource.com/setup_15.x | bash - && \ | ||
| apt-get install -y nodejs | ||
|
|
||
| RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - && \ | ||
| echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list && \ | ||
| sudo apt-get install -y yarn | ||
|
|
||
| RUN apt clean autoclean && rm -rf /var/lib/apt/* /var/cache/apt/* | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| DOCKER_COMPOSE_FILE=dockercompose.yml | ||
|
|
||
| docker-compose -f ${DOCKER_COMPOSE_FILE} down | ||
| docker-compose -f ${DOCKER_COMPOSE_FILE} build | ||
| docker-compose -f ${DOCKER_COMPOSE_FILE} up -d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| FROM python:3.9 | ||
|
|
||
| RUN pip install Flask | ||
| RUN pip install pandas | ||
| RUN pip install SQLAlchemy | ||
| RUN pip install psycopg2-binary | ||
|
|
||
| VOLUME /home/dvfapp | ||
|
|
||
| WORKDIR /home/dvfapp | ||
|
|
||
| ENTRYPOINT ["python", "app.py"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| FROM node:latest | ||
|
|
||
| COPY entrypoint.sh /entrypoint.sh | ||
| RUN ["chmod", "+x", "/entrypoint.sh"] | ||
|
|
||
| WORKDIR /home/dvfapp | ||
|
|
||
| ENTRYPOINT ["/entrypoint.sh"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #!/bin/bash | ||
|
|
||
| yarn | ||
| yarn start |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.