fablabs.io
fablabs.io copied to clipboard
The platform of the global Fab Labs Network
FabLabs
This is the official repository for fablabs.io platform project.
Fab labs provide widespread access to modern means for invention. They began as an outreach project from MIT’s Center for Bits and Atoms (CBA), and became into a collaborative and global network. You can find more information about Fab Labs on the Fab Foundation Website.
If you are a Fab labs entusiast and/or you would like to contribute to the project please feel free to get in touch by opening a new issue.
Getting started
The platform is built with Ruby on Rails. We recommend reading the guide.
You can develop locally, or by using docker-compose (advanced).
- Start by creating the config file and edit as needed
cp .env.example .env
Local development (recommended)
We recommend using rbenv to handle different Ruby versions, and nvm to handle Node versions.
Install dependencies and create a database:
-
npm i -
bundle -
rake db:setup -
rails s -
Visit http://localhost:3000
Tests
Run tests with:
bundle exec rake
Using docker-compose (optional, for advanced users)
-
Start the project:
docker-compose up app -
Create database (only the first time):
docker-compose exec app rake db:setupIf npm does not successfully install do:
docker-compose exec app npm i -
Add this to your
/etc/hosts:127.0.0.1 www.fablabs.local 127.0.0.1 api.fablabs.local -
API is served on http://api.fablabs.local:3000
-
Add test users and data with
docker-compose exec app rake db:seedThis will create a normal user ([email protected], password=password) and an admin user ([email protected], password=password)
-
Run tests with
docker-compose exec app rake db:setup RAILS_ENV=testdocker-compose exec app rake spec -
If you make changes to the code, rebuild the app and deploy the new image
docker-compose builddocker-compose up -d -
Backup your db at any time with the included script:
./scripts/docker-backup-db.sh
Getting an API Token
- Login to fablabs.io
- Go to the developer console (on the upper-right menu)
- Create a New application, or edit an existing one.
- Fill in the form, Redirect URI can be 'https://example.com'
- Submit
Copy the Personal access token
Verify the token is working with the following terminal command:
curl -X GET 'https://api.fablabs.io/0/me' -H 'Authorization: Bearer <your_personal_token>'
curl -X GET 'https://api.fablabs.io/2/labs?page=0&per_page=100' -H 'Authorization: Bearer <your_personal_token>'
Production notes
If you are running in production:
-
you need to setup the SSL hosts and .env vars from the docker-compose.yml
-
you must define Amazon S3 env vars, all thumbnails and images depend on this:
S3_BUCKET=your_fablabs.io
S3_KEY=<amazon key>
S3_SECRET=<amazon secret>
S3_REGION=<amazon region code>
- you need to run the assets pipeline to update public/assets
docker-compose exec app bundle exec rake tmp:clear
docker-compose exec app bundle exec rake assets:precompile
docker-compose restart app
Pull requests
All PRs are tested on Github Actions. Make sure the tests run.
Languages and translation
The project is now on Crowdin https://crwd.in/fablabsio
Use the i18n-tasks normalize before submitting language changes
Styleguide
There is a minimal styleguide on http://localhost:3000/styleguide
Use it and update it if you add new reusable classes
Versioning
Currently using this tool to manually handle versioning: https://github.com/gregorym/bump
Use this command to update the VERSION file + create a git tag
bump patch --tag
Then push the git tag with:
git push --tags
License
This project is licensed under the GNU Affero General Public License v3.0 (AGPL) - see the LICENSE.md file for details.
