Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker-compose for development #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docker-compose.yml
./dev/Dockerfile
dist
node_modules
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@

This is the Example Package for OS.js.

## Development

Easily run the application using `docker-compose`:

```bash
docker compose up
```

This will run an instance of `OSJS` on port 8000 with your application added to it. Every time anything changes inside the application source code, application will be built with new changes and added inside `OSJS` again.

Also, `config.js` inside `dev` folder is replaced by the `src/server/config.js` inside `OSJS`. If your app requires any specific options based on `config.js`, feel free to add your options and expect `OSJS` to be restarted and considering your options!

## Installation

```bash
Expand Down
18 changes: 18 additions & 0 deletions dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM osjs/osjs

WORKDIR /usr/src/osjs

RUN npm i -g watch-cli

COPY ./package.json ./src/packages/osjs-example-application/package.json
RUN cd ./src/packages/osjs-example-application && npm i

COPY ./dev/start.sh ./start.sh
RUN chmod +x ./start.sh

COPY . ./src/packages/osjs-example-application/
RUN cd ./src/packages/osjs-example-application && npm run build

RUN npm run package:discover

CMD ["./start.sh"]
46 changes: 46 additions & 0 deletions dev/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* OS.js - JavaScript Cloud/Web Desktop Platform
*
* Copyright (c) 2011-2020, Anders Evenrud <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Anders Evenrud <[email protected]>
* @licence Simplified BSD License
*/

//
// This is the server configuration tree.
// Guide: https://manual.os-js.org/config/#server
// Complete config tree: https://github.com/os-js/osjs-server/blob/master/src/config.js
//

// This file will be placed as src/server/config.js

const path = require('path');
const root = path.resolve(__dirname, '../../');

module.exports = {
root,
port: 8000,
public: path.resolve(root, 'dist'),
};
5 changes: 5 additions & 0 deletions dev/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
APP_NAME="osjs-example-application"

(cd ./src/packages/$APP_NAME && npm run watch) \
& (npx nodemon --ignore 'dist/**/*' --watch package-lock.json --watch src/server --watch package.json --watch src/packages src/server/index.js) \
& (watch -p "./src/packages/$APP_NAME/metadata.json" -c "npm run package:discover")
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3'

services:
osjs:
build:
context: .
dockerfile: ./dev/Dockerfile
ports:
- "8000:8000"
volumes:
- ./:/usr/src/osjs/src/packages/osjs-example-application
- ./dev/config.js:/usr/src/osjs/src/server/config.js
- /usr/src/osjs/src/packages/osjs-example-application/node_modules