Browse Source

Release hotfix

rigwild 1 year ago
parent
commit
72cd80e1e6

+ 2 - 0
.dockerignore

@@ -1,3 +1,5 @@
 node_modules
 npm-debug.log
 .git
+images
+dist

+ 0 - 12
Dockerfile_back

@@ -1,12 +0,0 @@
-FROM node:11.7.0-alpine
-
-# Back docker image
-COPY . /usr/src/app
-
-WORKDIR /usr/src/app
-
-EXPOSE ${PORT}
-
-RUN yarn install
-CMD yarn run api:start
-

+ 59 - 7
README.md

@@ -1,23 +1,74 @@
 # Antoine_Internship
-Travaux développés par Antoine dans le cadre de son stage de DUT2.
+A web app to collect data on noise detection by humans on images.
 
+## Download project
+```sh
+git clone https://gogs.univ-littoral.fr/Prise3D/Antoine_Internship.git
+cd Antoine_Internship
+```
 
 ## Run as a Docker instance
+### Configure
+Use the following environment variables to configure the application.
+| Option      | Default value | Description | Server | Client |
+| ----------- | ------------- | ----------- | :------: | :------: |
+| `PORT` | `5000` | The port used by the started application |  ✅  | ✅ |
+| `SERVE_CLIENT` | `true` | Should the server serve client (Fully local application) |  ✅  | ⬜️ |
+
 ### Run server + client
+Linux
 ```sh
 PORT=8080 SERVE_CLIENT=true docker-compose up
 ```
-### Run only the server
+Windows
+```bat
+SET PORT=8080
+SET SERVE_CLIENT=true
+docker-compose up
+```
+
+### Run server only
+Linux
 ```sh
 PORT=8080 SERVE_CLIENT=false docker-compose up
 ```
+Windows
+```bat
+SET PORT=8080
+SET SERVE_CLIENT=false
+docker-compose up
+```
 
-### Run only the client
+### Run client only
+Linux
 ```sh
 PORT=8080 docker-compose -f docker-compose.frontapp_only.yml up
 ```
+Windows
+```bat
+SET PORT=8080
+docker-compose -f docker-compose.frontapp_only.yml up
+```
+
+### Notice
+#### New version Docker build
+When using a new version of the project, you need to re-build the application with Docker.
+```sh
+# Server / Server + client versions
+docker-compose build
+
+# Client only version
+docker-compose -f docker-compose.frontapp_only.yml build
+```
 
-To change the port the server is running on set the environnements variables if necessary (see project setup part).
+### Using Windows
+When using Windows, it may happen that you can't properly run the containers because of Windows's path system being different. To circumvant this problem, you can do the [following steps](https://github.com/docker/compose/issues/4303#issuecomment-379563170).
+> 1. On **Command Line**: "_set COMPOSE_CONVERT_WINDOWS_PATHS=1_";
+> 2. Restart **Docker for Windows**;
+> 3. Go to **Docker for Windows** settings **>** Shared Drives **>** Reset credentials **>** select drive **>** Apply;
+> 4. Reopen **Command Line**;
+> 5. Kill the _Containers_;
+> 6. Rerun the _Containers_.
 
 ## Run on the file system
 ### Project setup
@@ -35,6 +86,7 @@ export NODE_ENV=production
 On Windows hosts :
 ```bat
 SET NODE_ENV=production
+SET SERVE_CLIENT=false
 ```
 
 ### Configuration 
@@ -52,17 +104,17 @@ Configure the project by modifying *[config.js](config.js)*.
 ### API
 #### Run the server
 ```sh
-yarn run api:start
+yarn run server:start
 ```
 
 #### Run the server with hot-reload for development
 ```sh
-yarn run api:dev
+yarn run server:dev
 ```
 
 #### Automatically fix the API code syntax with ESLint
 ```sh
-yarn run api:lint
+yarn run server:lint
 ```
 
 

+ 13 - 0
back.Dockerfile

@@ -0,0 +1,13 @@
+FROM node:11.7.0-alpine
+
+# Back docker image
+COPY . /usr/src/app
+
+WORKDIR /usr/src/app
+
+EXPOSE $PORT
+
+RUN yarn install
+
+# Build front if SERVE_CLIENT=true
+CMD if [ "$SERVE_CLIENT" == "true" ] ; then yarn run app:build && yarn run server:start ; else yarn run server:start ; fi

+ 1 - 1
docker-compose.frontapp_only.yml

@@ -5,7 +5,7 @@ services:
    frontapp_only:
       build:
           context: .
-          dockerfile: Dockerfile_front
+          dockerfile: front.Dockerfile
       image: frontwebapp
       ports:
           - "${PORT}:80"

+ 1 - 2
docker-compose.yml

@@ -5,7 +5,7 @@ services:
   backapp:
       build:
           context: .
-          dockerfile: Dockerfile_back
+          dockerfile: back.Dockerfile
       image: backapp
       ports:
           - "${PORT}:${PORT}"
@@ -15,4 +15,3 @@ services:
           PORT: $PORT
       volumes:
           - ./images:/usr/src/app/images
-  

Dockerfile_front → front.Dockerfile


+ 3 - 3
package.json

@@ -3,9 +3,9 @@
   "version": "0.1.0",
   "private": true,
   "scripts": {
-    "api:start": "node -r esm api/index.js",
-    "api:dev": "nodemon --exec npm run api:start",
-    "api:lint": "eslint api/ --fix",
+    "server:start": "node -r esm server/index.js",
+    "server:dev": "nodemon --exec npm run server:start",
+    "server:lint": "eslint server/ --fix",
     "app:dev": "vue-cli-service serve",
     "app:build": "vue-cli-service build",
     "app:lint": "vue-cli-service lint"

api/functions.js → server/functions.js


api/index.js → server/index.js


api/routes/getImage.js → server/routes/getImage.js


api/routes/index.js → server/routes/index.js


api/routes/listSceneQualities.js → server/routes/listSceneQualities.js


api/routes/listScenes.js → server/routes/listScenes.js