Skip to content

Commit

Permalink
feat: add api-server to docker-compose
Browse files Browse the repository at this point in the history
Documented the new instructions for setting up a dev environment.
  • Loading branch information
dennyabrain committed Mar 9, 2023
1 parent 0a49c89 commit 86063e3
Show file tree
Hide file tree
Showing 6 changed files with 1,667 additions and 18 deletions.
27 changes: 14 additions & 13 deletions browser-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Requirements :
- npm : v8.7.0^
- nodejs : 16.4.2^

Ensure that the following Environment Variables are available to your api-server process:
Ensure that the following Environment Variables are available to your api-server process.

```
NODE_ENV=development
Expand All @@ -40,45 +40,46 @@ DB_USERNAME: XXXXXXXXXXX
DB_PASSWORD: XXXXXXXXXXX
```

Alternatively, create a `development.env` file with the variables in the `api-server` directory.

## For Development

```
git clone https://github.com/tattle-made/OGBV.git
cd browser-extension/
cd plugin && npm install
cd ..
cd api-server && npm install
docker-compose up
```

Now you can run the development server for the following entities in different tabs/windows and monitor their logs :
| Service | Command To Run |
| --- | --- |
| api server (common for all browsers) | cd api-server && nodemon index.js |
| content script and options page for Chrome | cd plugin && npm run dev:chrome |
| content script and options page for Firefox | cd plugin && npm run dev:firefox |
Setup the database by running `docker exec -it api-server npx sequelize-cli db:migrate`. You should be able to see uli related tables in the sql database now.

To run the the api server run `docker exec -it api-server npx sequelize-cli nodemon index.js`.

To run the plugin development server, run `cd plugin` and then the following :

1. For Chrome : `npm run dev:chrome`
2. For Firefox : `npm run dev:firefox`

If all services run correctly, you should be able to load the plugin from `plugin/dist` folder into Chrome/Brave/Firefox.

#### For Windows only

If you are developing on Windows and run into errors where certain files are not being copied, go to `plugin/package-json` and in the commands `npm run dev:chrome` and `npm run dev:firefox`, replace the command `cp` with `copy` and the front slashes in all the file paths to double back slashes. Secondly, running the commands mentioned in the table above will create a `-p` and a `dist` folder everytime which you will need to delete in order to generate a new distribution to reflect major changes.
If you are developing on Windows and run into errors where certain files are not being copied, go to `plugin/package-json` and in the commands `npm run dev:chrome` and `npm run dev:firefox`, replace the command `cp` with `copy` and the front slashes in all the file paths to double back slashes. Secondly, running the commands mentioned in the table above will create a `-p` and a `dist` folder everytime which you will need to delete in order to generate a new distribution to reflect major changes.

## Installing unreleased extension
## Installing unreleased extension

To learn how to install unreleased extension in your browser follow the instructions [here](https://webkul.com/blog/how-to-install-the-unpacked-extension-in-chrome/)

Look into individual README within the `api-server` and `plugin` folder for more info.

## Cleaning changes

In order to remove the dist folder to start with a new distribution, run the following command:
In order to remove the dist folder to start with a new distribution, run the following command:

```
cd plugin && npm run dev:clean
```


## For Production

For Chrome/Brave:
Expand Down
5 changes: 4 additions & 1 deletion browser-extension/api-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
FROM node:15.7.0-alpine3.12
FROM node:16-alpine
WORKDIR /app

COPY package.json /app/package.json
RUN cd /app
RUN npm install
RUN npm install sequelize-cli
RUN npm install -g nodemon
COPY . .

CMD ["node", "index.js"]
2 changes: 1 addition & 1 deletion browser-extension/api-server/db/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
username: "tattle",
password: "tattle_pw",
database: "uli_dev",
host: "127.0.0.1",
host: "db",
dialect: "mysql",
},
test: {
Expand Down
Loading

0 comments on commit 86063e3

Please sign in to comment.