ipfspics/ipfspics-server

Missing installation instructions + database structure

victorb opened this issue ยท 17 comments

Something that is missing is how to install this on your own machine. Would be good to have in the readme.

Also, as a part of the installation instructions, there is no way to easily recreate the database.

I will make an SQL file in a couple of hours, I'll send it to you as soon as it's done.

Put it in the repository :)

I'll create a wiki page for the installation instructions. The inner workings will change a lot very soon (see #12), so I think it would be a good idea to write the instructions in a place where they can be updated easily.

I'll also add a link in the readme.

I have started writing the instructions, they are not done but they might still be useful. I will continue them after my classes.

I'm creating a "docker:ized" version of ipfs pics, however, I'm new to docker so things are moving along slowly. I'll post as soon as I have something.

Here are some issues that have come up when trying trying to make ipfs-pics/server work in docker:

  • As already mentioned by Victor, the missing database structure. I've got a copy of the structure from @didiercf:
CREATE TABLE hash_info (
       hash VARCHAR(46) UNIQUE,
       type CHAR(5),
       nsfw TINYINT(1),
       sfw tinyint(1) NOT NULL,
       backed_up SMALLINT(1),
       first_seen INT(11),
       banned TINYINT(1),

       PRIMARY KEY (hash)
);

CREATE TABLE votes (
       hash VARCHAR(46) UNIQUE,
       vote_type tinytext NOT NULL,
       ip varchar(45) NOT NULL,
       timestamp int(64) NOT NULL,

       PRIMARY KEY (hash)
);

I'd create a pull request, but I'm not sure where to put it, which brings me to my next point:

  • Folder structure: to include the schema, and other stuff which should not be open to the public, it would perhaps be better to put the publicly available files in a sub-directory. I'm not sure what is the best way to structure PHP-applications, but here is a suggestion (based on [1] [2]):
app/ (contains index.php, basically everything that is in the project root right now etc)
db/ (contains database schema, migrations eventually)
docker/ (contains docker-composer.yml and docker contains)
config/ (contains the database-configuration) 
ipfs-bridge/ (contains server.js)

I can set this up as long as we agree on some structure.

[1] http://stackoverflow.com/questions/29850964/project-layout-with-vagrant-docker-and-git
[2] http://stackoverflow.com/questions/1387547/what-is-the-most-scalable-php-based-directory-structure-for-a-large-site

For the database structure, I've improved some points but I see that you've set the primary key to hash which I didn't and realize now that it's pretty clever. I'm on the verge of putting an SQL file in the repo, hoping it'll be good! ๐Ÿ˜†

I've uploaded 4 SQL files in the db directory, they should create the whole database automatically! ๐Ÿ‘

@arvidj I like your sugestion.

app/ (contains index.php, basically everything that is in the project root right now etc)
db/ (contains database schema, migrations eventually)
docker/ (contains docker-composer.yml and docker contains)
config/ (contains the database-configuration) 

I'd like to leave server.js at the root, I want to replace it very soon with a php class that curls the ipfs web api instead (see #12).

app/ folder and db/ sounds pretty good. Docker stuff you generally want to keep in the root folder. Database configuration and things shouldn't be in SCM at all, rather, put it in environment variables where it's safe. Take a look at http://12factor.net/ for good tips.

The nodejs bridge shouldn't exists at all in the first place.

Thanks for sharing the structure! Will be easier for people to get up and running! ๐Ÿ‘

Why four different files instead of one by the way?

@victorbjelkholm I had trouble making the file run more then one query so I've decided to put them in four while I found a better way!

I have followed the instructions on another machine and I have successfully installed ipfs.pics. If anyone else is successful, I will update the readme and close this issue.

I have started a new issue for the config. It is a good idea. I think we should still go ahead with the config folder while we discuss how to implement this. It is more secure than the current setup.

I know next to nothing about docker. How many files will there be?

I think we can close this issue. I've created a separate issue #22 for dealing with docker.

@arvidj Are you making a pull request with the directory changes or do you prefer I do it?

I don't think I'll have time to do it before the week-end, but if you can hold on I'll do it then. I think the following structure would be a good end-goal:

db/
app/
.env.dist (see #21, alternatively just move pswd.php here for now)
Dockerfile (see #22, can be added later)
README
LICENSE 
...

I approve this design ๐Ÿ‘