Parcourir la source

Use of docker for deploy website

Jérôme BUISINE il y a 4 ans
Parent
commit
507f912147
3 fichiers modifiés avec 90 ajouts et 3 suppressions
  1. 21 0
      Dockerfile
  2. 43 0
      Makefile
  3. 26 3
      README.md

+ 21 - 0
Dockerfile

@@ -0,0 +1,21 @@
+from python
+
+COPY . /usr/src/app
+WORKDIR /usr/src/app
+
+# Server port
+EXPOSE 8000
+
+RUN apt-get update
+
+# update project source code if necessary (use by default https protocol)
+RUN git remote set-url origin https://github.com/prise-3d/Thesis-WebExpe-Django.git
+RUN git pull origin master
+
+# Install dependencies and prepare project
+RUN python --version
+RUN pip install -r requirements.txt
+RUN python manage.py makemigrations
+RUN python manage.py migrate
+
+CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

+ 43 - 0
Makefile

@@ -0,0 +1,43 @@
+# get information about webexpeinstance
+WEBEXPE_RUN=$(docker ps | grep webexpeinstance)
+WEBEXPE_STOP=$(docker ps -a | grep webexpeinstance)
+
+build:
+	@echo "----------------------------------------------------------------"
+	@echo "Update of djangowebexpe image"
+	@echo "----------------------------------------------------------------"
+	docker build --no-cache . --tag djangowebexpe
+	@echo "----------------------------------------------------------------"
+	@echo "Image is now build you can run instance using 'make run'
+	@echo "----------------------------------------------------------------"
+
+run: 
+	@echo "----------------------------------------------------------------"
+	@echo "Process to run new instance"
+	@echo "----------------------------------------------------------------"
+	docker run -p 8000:8000 -it -d --name webexpeinstance djangowebexpe
+	@echo "----------------------------------------------------------------"
+	@echo "Your docker instance is now launched with name 'webexpeinstance'"
+	@echo "Your website is now accessible at http://localhost:8000"
+	@echo "----------------------------------------------------------------"
+
+stop:
+	@echo "----------------------------------------------------------------"
+	@echo "Process to stop current instance"
+	@echo "----------------------------------------------------------------"
+	docker stop webexpeinstance
+	@echo "----------------------------------------------------------------"
+	@echo "App is now stopped"
+	@echo "----------------------------------------------------------------"
+
+remove:
+	@echo "----------------------------------------------------------------"
+	@echo "Process to stop current instance"
+	@echo "----------------------------------------------------------------"
+	docker stop webexpeinstance
+	docker rm webexpeinstance
+	@echo "----------------------------------------------------------------"
+	@echo "App is now stopped and removed"
+	@echo "----------------------------------------------------------------"
+
+deploy: build run

+ 26 - 3
README.md

@@ -6,15 +6,17 @@ Web site which contains experiences on synthesis images (perception of noise).
 
 ## Installation
 
-## Requirements
+### 1. Manually
+
+#### Requirements
 
 You need to have python, pip
 
 ```
-pip install -r requirements.txt
+pip install -r requirementst.txt
 ```
 
-## Run server
+#### Run server
 
 And then, run the server :
 
@@ -28,6 +30,27 @@ or if you want to precise a specific port number :
 python project/manage.py runserver 8080
 ```
 
+### 2. Using docker (recommended)
+
+You can use make commands:
+
+```
+make build
+```
+
+```
+make run
+```
+
+Or simply:
+
+```
+make deploy
+```
+
+Will run `build` and `run` commands at once.
+
+You also have `stop` and `remove` commands to stop and remove current generated docker instance.
 
 ## How to contribute ?