Search code examples
gitdrupalworkflowvpsgogs

Web development structure on multiple devices


I have a question regarding web development. (I mostly make Drupal websites) I've been trying to figure this out but I just can't find the best workflow. I will explain my issues:

I have a laptop (which I use for school mostly) And a pc. I would like to use both for development.

I figured the best practice would be to use something like GitHub. But I didn't want everything to be public. So I rented a vps and set up GOGS (a self hosted GitHub alternative) Everything works fine and I can use this to push and pull my work to other devices.

My current problem; If I for example develop a Drupal website I do the installation on my laptop. I need to do the same installation on my pc too. (as I am using a .gitignore. not the whole installation will be pushed and pulled.)

Is this the way i should work? I thought of some alternatives, but I don't know if they are better;

  • I could not use a .gitignore, pushing and pulling the whole project to my vps. even files with passwords.
  • I could not use my gogs vps and use a cloud service, or perhaps a NAS to sync one project to the other device. And then use local git to make repositories in the cloud service too.

I would like to ask you what the best way would be here? Thanks!


Solution

  • Little bit overhead the self-hosted Git, I think. Simply create an account on https://bitbucket.org or https://gitlab.com. They have free private repos.

    But yes, in principle, the way you got it working is the right way.

    • Decentralized code repository
    • Local development
    • Code release to live instance (server)

    Drupal now already comes with certain things "preconsidered" when it comes to development with Git. It already has a correctly preconfigured .gitignore file, that for example initially excludes the settings.php file, which holds sensitive information (most important: database credentials). This file will be different on all your local and live instances of the site. You may want to ignore other files as well (.htaccess, robots.txt etc.). This depends mainly on your workflow.

    Next "problem": the database. As you already might have discovered, certain things only exist in the database. Not in code. Nodes, pages, settings. This problem is generally solved by "down-streaming" database-dumps from live in direction to local (never in the opposite direction). So you'll normally create a database dump then from the live instance (on your live server) and then import that database on your dev server and in your local instances. So you may now define one base instance and always take the database from there. (Similar applies for all assets in the /files folder – simply download that folder from live to your local instance.)

    In Drupal 7 big parts of this "problem" (or challenge) usually was solved with the Features module, which allowed you to export database settings from your local Drupal database into certain features modules and these settings then could be commited, pushed, pulled and re-imported into the database on the live instance. In Drupal 8 this challenge mainly got solved by Configuration Management, where a lot of these settings get exported into *.yml files which then could be distributed and imported on all other instances.

    To make Drupal development a little bit easier (when it comes to export and import databases or configuration) there are a bunch of tools available.

    But you can also make use of other tools you prefer (NPM, Bower, Gulp etc.). And then let them do the donkey's work.

    Most of the information I provided will automatically get clearer in the very moment when you start to work together on one project with others.

    Please feel free to ask one or two exact additional questions in the comments.