diff --git a/prod.Dockerfile b/Dockerfile similarity index 100% rename from prod.Dockerfile rename to Dockerfile diff --git a/dev.Dockerfile b/Dockerfile.dev similarity index 100% rename from dev.Dockerfile rename to Dockerfile.dev diff --git a/README.md b/README.md index e1e533330..44370c683 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,13 @@ This method only requires that you have the `Docker engine` and `docker-compose` - Added benefits to this method other than the ones that docker already provides is you are not confined to developing in the docker container. You can also develop using your local modules as defined above. ```zsh -docker-compose up #Starts the react-dev-server on localhost:3000 +docker-compose -f docker-compose.dev.yml pull fossology_server && docker-compose -f docker-compose.dev.yml up #Starts the react-dev-server on localhost:3000 ``` +On Windows you might have to forego the `&&` and run both commands individually. + +Running the `docker-compose pull ...` command each time you run the docker container isn't required but recommended so as to get the latest fossology image. + This will start the react-dev-server on localhost on `port:3000`. The docker image can then be used using http://IP_OF_DOCKER_HOST:3000/ user fossy password fossy. (IP_OF_DOCKER_HOST is generally localhost) @@ -55,20 +59,20 @@ The docker image can then be used using http://IP_OF_DOCKER_HOST:3000/ user foss You can even run it detached in the background using the -d option. ```zsh -docker-compose up -d +docker-compose -f docker-compose.dev.yml up -d docker-compose logs #To view server logs ``` npm packages can be installed using `docker-compose exec` ```zsh -docker-compose exec -w /usr/src/fossologyui fossologyui_server yarn add --save #Install npm package for react-dev-server +docker-compose -f docker-compose.dev.yml exec -w /usr/src/fossologyui fossologyui_server yarn add --save #Install npm package for react-dev-server ``` Once done developing, you can clean up running containers and networks using: ```zsh -docker-compose down +docker-compose -f docker-compose.dev.yml down ``` #### Production @@ -77,7 +81,6 @@ For production level deployment you can use: ```zsh docker build \ --f prod.Dockerfile \ -t fossologyui:react1.0 \ --build-arg REACT_APP_SERVER_URL="localhost/repo/api/v2" \ --build-arg REACT_APP_HTTPS="false" . @@ -94,20 +97,20 @@ The docker image would then be hosted on http://IP_OF_DOCKER_HOST:3000/ user fos Alternatively, you can also deploy it using docker-compose: ```zsh -docker-compose -f docker-compose.prod.yml up +docker-compose up ``` You can even run it detached in the background using the -d option. ```zsh -docker-compose -f docker-compose.prod.yml up -d +docker-compose up -d docker-compose logs #To view server logs ``` Deployed image can be pulled down using: ```zsh -docker-compose -f docker-compose.prod.yml down +docker-compose down ``` This will clean up running containers and networks. diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 000000000..d804ce53f --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,63 @@ +# FOSSology docker-compose file + +# Copyright (C) 2022 Vineet Vatsal (vineetvatsal09@gmail.com) + +# SPDX-License-Identifier: GPL-2.0 + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Description: docker-compose file for development environment. + + +version: "3.9" + +services: + fossologyui_server: + build: + context: Dockerfile.dev + args: + - REACT_APP_SERVER_URL=localhost/repo/api/v2 + - REACT_APP_HTTPS=false + image: fossologyui:react1.0 + command: ../node_modules/.bin/react-scripts start + ports: + - "3000:3000" + volumes: + - .:/usr/src/fossologyui/app:delegated + # bind-mounting these three files in will let you add packages during development without rebuilding + # for example, to add bower to your app while developing, just install it inside the container + # and then nodemon will restart. Your changes will last until you "docker-compose down" and will + # be saved on host for next build + # NOTE: this won't work on Docker Toolbox (virtualbox) which doesn't bind-mount single files + # docker-compose exec node npm install --save bower + - ./package.json:/usr/src/fossologyui/package.json + - ./package-lock.json:/usr/src/fossologyui/package-lock.json + - ./yarn.lock:/usr/src/fossologyui/yarn.lock + # this is a workaround to prevent host node_modules from accidently getting mounted in container + # in case you want to use node/npm both outside container for test/lint etc. and also inside container + # this will overwrite the default node_modules dir in container so it won't conflict with our + # /usr/src/fossologyui/node_modules location. + - notused:/usr/src/fossologyui/node_modules + + fossology_server: + image: fossology/fossology:latest + ports: + - "8081:80" + volumes: + - repository:/srv/fossology/repository/ + - database:/var/lib/postgresql/data + +volumes: + notused: + repository: + database: diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml deleted file mode 100644 index d31e85136..000000000 --- a/docker-compose.prod.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: "3.9" - -services: - fossolgyui_server: - build: - context: prod.Dockerfile - args: - - REACT_APP_SERVER_URL=localhost/repo/api/v2 - - REACT_APP_HTTPS=false - image: fossologyui:react1.0 - ports: - - "3000:3000" - command: yarn start \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index ef866575b..03111902b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,32 +1,34 @@ +# FOSSology docker-compose file + +# Copyright (C) 2022 Vineet Vatsal (vineetvatsal09@gmail.com) + +# SPDX-License-Identifier: GPL-2.0 + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Description: docker-compose file for production environment + + version: "3.9" services: - fossolgyui_server: + fossologyui_server: build: - context: dev.Dockerfile + context: Dockerfile args: - REACT_APP_SERVER_URL=localhost/repo/api/v2 - REACT_APP_HTTPS=false image: fossologyui:react1.0 - command: ../node_modules/.bin/react-scripts start ports: - "3000:3000" - volumes: - - .:/usr/src/fossologyui/app:delegated - # bind-mounting these three files in will let you add packages during development without rebuilding - # for example, to add bower to your app while developing, just install it inside the container - # and then nodemon will restart. Your changes will last until you "docker-compose down" and will - # be saved on host for next build - # NOTE: this won't work on Docker Toolbox (virtualbox) which doesn't bind-mount single files - # docker-compose exec node npm install --save bower - - ./package.json:/usr/src/fossologyui/package.json - - ./package-lock.json:/usr/src/fossologyui/package-lock.json - - ./yarn.lock:/usr/src/fossologyui/yarn.lock - # this is a workaround to prevent host node_modules from accidently getting mounted in container - # in case you want to use node/npm both outside container for test/lint etc. and also inside container - # this will overwrite the default node_modules dir in container so it won't conflict with our - # /usr/src/fossologyui/node_modules location. - - notused:/usr/src/fossologyui/node_modules - -volumes: - notused: + command: yarn start \ No newline at end of file