Code Monkey home page Code Monkey logo

userdb's Introduction

HKFree UserDB

Powerful HKFree.org user and IP management system

Developed by powerful team - Evil, ZitnyP, Bkralik & pavkriz

Before you begin

Installation

git clone https://github.com/HKFree/UserDB.git
cd UserDB
composer install
cp app/config/config.local.DIST.neon app/config/config.local.neon
vi app/config/config.local.neon www/.htaccess docker-compose.yml
php www/index.php migrations:continue

Development

Editor

Please use editor or IDE that obeys .editorconfig settings

Run locally

Override environment variables defined in docker-compose.yml using docker-compose.override.yml when necessary. Don't forget that some settings are still present in app/config/config.local.neon.

docker-compose build
docker-compose up
docker-compose exec web composer install
docker-compose exec web php www/index.php migrations:continue

Now the app is up and running in Docker on host's port 80, PhpMyAdmin on host's port 8080. If you don't know your docker's IP, docker-machine list is your friend.

Build, commit

git pull origin master
composer install
php www/index.php migrations continue
# develop your freaking cool feature
git pull origin master
git push origin master

Deployment

Useful stuff to fix several Nette's gotchas: Nedostatky Nette při přechodu ze Symfony2

Run git remote add production ssh://[email protected]/opt/UserDB.git first time (replace user with your username at userdb.hkfree.org).

Run git push production master in order to fully deploy the app.

When something goes wrong, try to run (cd /opt/UserDB.git; hooks/post-receive) manually on the server.

See git-hooks/post-receive.sample for more details what happens during deployment on server side.

Jobs to be run

Run php www/index.php app:update_locations regularly in order to update users' locations based on their addresses.

Crontab record example: */5 * * * * (docker exec userdb php www/index.php app:update_locations) 2>&1 | /usr/bin/logger -t userdb_locations

Making DB changes

###Creating new change-script

Run docker exec -it userdb_web_1 php www/index.php migrations:create s short-description-of-the-change and edit the change-script created.

  • s = structures (applied always)
  • b = basic-data (eg. lists-of-values, applied always)
  • d = dummy-data (eg. testing records, applied only when --production omitted, should not be run on production)

Applying changes

Make sure the cache is clean by running rm -rf temp/cache and run php www/index.php migrations:continue --production in order to apply the change-scripts to the DB configured in neon config.

On development or testing machines

Omit --production when you want to apply dummy-data scripts too (on development or testing machine).

You can run php www/index.php migrations:reset in order to drop all tables in the database and create them from scratch running all change-scripts. Run it on dev/test machine in order to test that the whole schema is completely described in change-scripts. DO NOT RUN IN PRODUCTION! WILL DELETE ALL DATA!

On moving to nextras/migrations

Before applying migrations to a database that was not versioned before, run the following code (it pretends that all initial change-scripts has been run):

CREATE TABLE `migrations` (`id` int(10) UNSIGNED NOT NULL,
  `group` varchar(100) NOT NULL,
  `file` varchar(100) NOT NULL,
  `checksum` char(32) NOT NULL,
  `executed` datetime NOT NULL,
  `ready` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `migrations` (`id`, `group`, `file`, `checksum`, `executed`, `ready`) VALUES
(1, 'structures', '2016-10-23-102733-new-init-schema.sql', '107a87552ba751e059e8197a4194ae5e', '2016-10-23 22:38:06', 1),
(2, 'basic-data', '2016-10-23-110900-new-init-data.sql', 'e26dba9c81ad0a52e875c1bc0fc13863', '2016-10-23 22:38:14', 1);
ALTER TABLE `migrations`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `type_file` (`group`,`file`);
ALTER TABLE `migrations`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

Accessing API

Open swagger.yaml interactive docs and try some operations. You'll need the credentials (click Authorize in interactive docs). Create credentials in UserDB: Oblast - Zobrazit podrobnosti AP - Editovat - API klíče.

License

Push to production server2

userdb's People

Contributors

bkralik avatar cermis avatar evildivine avatar pavkriz avatar vpithart avatar xjrk58 avatar zitnyp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.