Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danielres/mytribe
a directory of friends for local/remote communities | highly experimental | ORM-less | nodejs + react + redux | docker-cloud CD + CI | lean event-sourcing
https://github.com/danielres/mytribe
ci create-react-app docker docker-cloud docker-compose droplet functional functional-programming jest knexjs nodejs orm-less react redux
Last synced: about 15 hours ago
JSON representation
a directory of friends for local/remote communities | highly experimental | ORM-less | nodejs + react + redux | docker-cloud CD + CI | lean event-sourcing
- Host: GitHub
- URL: https://github.com/danielres/mytribe
- Owner: danielres
- Created: 2017-05-29T18:26:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-02-21T15:11:40.000Z (almost 3 years ago)
- Last Synced: 2024-04-15T01:22:24.018Z (9 months ago)
- Topics: ci, create-react-app, docker, docker-cloud, docker-compose, droplet, functional, functional-programming, jest, knexjs, nodejs, orm-less, react, redux
- Language: JavaScript
- Homepage:
- Size: 378 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Docker-Node-React test project
Warning: this Readme is outdated. Stay tuned for updates !
This project is a personal experiment for running a javascript app with decoupled frontend and backend using Docker.
The whole application is composed of several independent layers assembled together using docker-compose:
- in all environments:
- the `web` container is the core of the application
- the `db` container provides a postgresql database- in production only:
- `https-portal` enables https on the whole application
- the `auth` container has to be used on a subdomain of the app, and provides authentication using various providers like FacebookThis whole stack can be executed locally for development and remotely in production using `docker-compose` commands.
In production, this whole stack can be hosted for example on Digital Ocean's cheapest instance (5$/month).This might hopefully become a very convenient base for rapid development of simple applications with a small amount of users, with the ability to scale up easily if necessary.
The app is composed of:
- a `web` container with:
- a frontend (create-react-app)
- a backend (express.js)
- a `db` container (postgres)And, in production:
- an `https-portal` enabling https for the whole app
- `login-with`: a microservice in charge of Facebook authentication (can easily configured for more auth providers like Google, Twitter, ...)Deployment:
- [TODO]
## Configuration:
The app needs a number of environment variables to be set:
- used in all environments:
- `PGPASSWORD`
- `PGUSER`
- `PGDB`- used in production only:
- `HTTPSDOMAINS`
- `LW_JWT_SECRET`
- `LW_SESSION_SECRET`
- `LW_SUBDOMAIN`
- `LW_FACEBOOK_APPID`
- `LW_FACEBOOK_APPSECRET`In development, these needed env variables are set automatically, reading from the `.env` file.
In production, you need to define these variables yourself.
Here is an example launch command for production:
```bash
PGPASSWORD="myDbPassword" \
PGUSER="myDbUser" \
PGDB="myDbName" \
HTTPSDOMAINS="mydomain.com -> http://web:3001, login.mydomain.com -> http://auth:3000" \
LW_JWT_SECRET="someComplicatedString" \
LW_SESSION_SECRET="someOtherComplicatedString" \
LW_SUBDOMAIN="login.mydomain.com" \
LW_FACEBOOK_APPID="123444445555555" \
LW_FACEBOOK_APPSECRET="js4nvt3eog7mp49042240f350790be3e" \
docker-compose -f docker-compose.production.yml up
```## Setting up the Docker host
Recommended host system: a Digital Ocean's standard droplet with Ubuntu 14.04. (newer Ubuntu versions are not well suppoprted by `docker-machine`)
If you want to use a minimal Digital Ocean droplet for 5$/month (512 mb RAM, 20Gb Disk).
`docker-machine create --driver digitalocean --digitalocean-access-token=YOUR_DIGITALOCEAN_ACCESS_TOKEN --digitalocean-size 512mb YOUR_DOCKER_MACHINE_NAME`
This is the cheapest option available and comes with limitations that require some little tweaks. The main problem is that the droplet doesn't have enough RAM to be able to complete the `npm install` (or `yarn install`) command.
Luckily, they provide more than enough hard disk space for us to set up a 1Gb swapfile, which solves our probem.
### Setting up the swapfile (tested on the Digital Ocean Ubuntu 14.04 droplet):
Access the host's terminal through ssh, then run the following command on the host:
`fallocate -l 1G /swapfile && chmod 600 /swapfile && mkswap /swapfile && sudo swapon /swapfile && swapon --show`
With `docker-machine`, from your own machine:
`docker-machine ssh YOUR_DOCKER_MACHINE_NAME "fallocate -l 1G /swapfile && chmod 600 /swapfile && mkswap /swapfile && sudo swapon /swapfile && swapon --show"`
This will create the swapfile needed for the build to complete.
## Running commands through Docker
- [TODO, but in short: check package.json for ready to use npm scripts going through Docker]