Skip to content
This repository has been archived by the owner on Sep 23, 2022. It is now read-only.

Commit

Permalink
Add docker configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierstoval committed Oct 22, 2016
1 parent 92951d0 commit aa034b3
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
@@ -0,0 +1,5 @@
vendor
backend/build
backend/phpunit.xml
node_modules
frontend/public/bundle.js
4 changes: 1 addition & 3 deletions .gitignore
@@ -1,7 +1,5 @@
vendor
.crossbar
node_modules

backend/build
backend/phpunit.xml
node_modules
frontend/public/bundle.js
58 changes: 37 additions & 21 deletions README.md
Expand Up @@ -7,51 +7,67 @@ Sn4k3 - next generation MMO

#### Documentation index

* [Installation](#installation)
* [Execute](#execute)
* [Installation](#install)
* [Run](#run)
* [Bottlenecks](#nottlenecks)
* [Backend readme](backend/README.md)
* [Frontend readme](frontend/README.md)

# Installation
# Requirements <small>(if you don't have Docker)</small>

Install dependencies
* PHP >=7.0
* Python >=2.7 (with `pip`)
* NodeJS >=4.4 (with `npm`)

```bash
# Root install of crossbar
pip install crossbar
# Install

## With Docker

Just run `docker-compose build`.

# Backend dependencies
cd backend/
composer install
## Without Docker

# Frontend dependencies
cd frontend/
npm install
Execute all these commands directly from the root directory of the repository.

```bash
pip install crossbar
composer --working-dir=backend install
npm --prefix=frontend install
npm run build
# In dev, you can run this:
npm run watch
```

Configure your web-server at `frontend/public`
# Run

## With Docker

:information_source: If you want to install it with docker, please follow this link:<br>
http://crossbar.io/docs/Installation-on-Docker/
Just execute `docker-compose up -d`

# Execute
And go to `127.0.0.1:8080`.

## Without docker

You will need at least 3 terminals for this, because all apps need to be run independently.

Run Crossbar middleware instance

```bash
crossbar start
crossbar start --config=crossbar/config.json
```

And run the php broadcast application
Run the php broadcast application

```bash
php backend/broadcast.php
```

And finally execute nodejs static server

```bash
node frontend/server.js
```

And go to `127.0.0.1:8080`.

# Bottlenecks

## Collisions
Expand Down
19 changes: 19 additions & 0 deletions backend/Dockerfile
@@ -0,0 +1,19 @@
FROM php:7-alpine

RUN mkdir /app

WORKDIR /app

# Install composer for dependency installation
RUN php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/local/bin --filename=composer \
&& chmod +x /usr/local/bin/composer

COPY ./ /app

ENV COMPOSER_ALLOW_SUPERUSER=1

RUN composer --working-dir=/app install --optimize-autoloader --classmap-authoritative --no-interaction --prefer-dist --no-scripts

EXPOSE 80

CMD ["php", "broadcast.php"]
3 changes: 3 additions & 0 deletions crossbar/Dockerfile
@@ -0,0 +1,3 @@
FROM crossbario/crossbar

COPY config.json /node/.crossbar/config.json
File renamed without changes.
18 changes: 18 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,18 @@
version: '2.0'

services:
crossbar:
build: ./crossbar/
image: crossbario/crossbar
ports:
- '7777:8080'

broadcaster:
build: ./backend/
ports:
- '8888:80'

frontend:
build: ./frontend/
ports:
- "8080:8080"
4 changes: 4 additions & 0 deletions frontend/Dockerfile
@@ -0,0 +1,4 @@
FROM node:onbuild

RUN chmod a+x node_modules/.bin/*
RUN npm run build
2 changes: 1 addition & 1 deletion frontend/server.js
Expand Up @@ -3,7 +3,7 @@ var http = require('http');
var app = express();
var server = http.createServer(app);

const PORT = 80;
const PORT = 8080;

// Handle server errors
server.on('error', function (e) {
Expand Down

0 comments on commit aa034b3

Please sign in to comment.