Skip to content

Commit

Permalink
Renamed prod and dev Dockerfiles and docker-compose files. Added foss…
Browse files Browse the repository at this point in the history
…ology/fossology:latest as a service in dev docker-compose file.
  • Loading branch information
pret3nti0u5 committed Feb 18, 2022
1 parent 1a015a9 commit c9a75ca
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 43 deletions.
File renamed without changes.
File renamed without changes.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,34 @@ 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)

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 <package name> #Install npm package for react-dev-server
docker-compose -f docker-compose.dev.yml exec -w /usr/src/fossologyui fossologyui_server yarn add --save <package name> #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
Expand All @@ -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" .
Expand All @@ -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.
Expand Down
63 changes: 63 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -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:
13 changes: 0 additions & 13 deletions docker-compose.prod.yml

This file was deleted.

46 changes: 24 additions & 22 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c9a75ca

Please # to comment.