Developing with Drupal 9 including composer, drush and Docker

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to another uh drupal uh whirlwind another two hours together with drupal 9. i notice in my youtube history that there was a drupal 8 video that went for almost 2 hours and i've pretty much recorded another two hours with drupal 9. not much has changed except a lot in terms of the layout in terms of some of the processes that we can use to get drupal up and running so more than anything else in the ensuing two and a half years i've i've learned more about being able to deploy drupal in multi-tier applications in in containerized environments and and that's what this video is going to try to capture so what you see on the screen at the moment is the specification of what we want to build today so our two hours together involves us creating what is the specification of a document management system it's a policy system and our thinking is that we have a workflow and that workflow involves an author who creates policies and an editor that is going to approve those policies um and create categories and and take that policy through a life cycle through through a um an archival process uh we have users and i think in this configuration anonymous people can browse the policies by category and see individual policies that have gotten to the published stage a few very specific business rules each policy must have a unique kind of index associated with it [Music] we want wcag 2.1 compliance in terms of its visual structure content needs to be in some kind of structured order um and breadcrumbs allow us to be able to move up and down a hierarchy of um a category subcategory category so that's the specification in a nutshell and we'll get straight ahead with installing drupal and configuring it so you're in my local host terminal and the terminal represents a 30 year old technology well probably more 50 year old technology um but bear with me on this because uh what we're going to try to do is both download and configure drupal non-interactively and when i say non-interactively i mean in such a way that we could can it into a script so that [Music] we can instantiate in an automated way so what i'm doing in this command line can essentially be pasted into another file and then executed when we need it for production purposes or when we need it for staging purposes so in in the development stage it's obviously preferable to be working localhost because the latency is extremely low and we're going to spend a lot of time interacting over http and the lowest latency connections are the ones with zero hops so uh we we we want to work localhost um and essentially what i've done here is i've used a dependency manager called composer and composer gives us a an interface into everything php everything php that the developer would need so it represents all of the libraries all of the the frameworks all of the content management systems that are developed using uh php there are others for other languages so npm you might have heard for javascript and pip you might have heard for python so each has their own different different dependency manager where we can look for software and extend our own code to be achieving um new and interesting um things so what i'm doing here is i'm i'm going to install some dependencies on top of drupal so if i pull the drupal core down what i want to do is i want to bring down a extra bit of command line utility called drush and what that allows us to do is to make permanent configuration changes to our drupal instance outside of the administration panel that we would normally access over http and again that just allows us to be able to um extract a uh a canned process or or a pre-determined activity so things like uh site updates um database schema updates cache clearing entity creation [Music] theme creation even module creation can all be done within this interface it would also be something that we could do on a on a timed basis and that is at midnight every night we could dump the database um and then uh push it via get maybe up to some kind of a repository somewhere so that we can have a history of all the backups that have taken place um for the last n number of times um and also the file system so if anyone's uploaded any images or have uh pdfs or what have you during the process of managing content we can take a backup of that offline and even better we can we can have it into a uh into a code repository where the next instance the next development instance that we create on our local machine would would identically replicate exactly what production looks like so we don't have to go through the pain of of manually backing up and and what have you we can we can sort of shut the site down one sunday afternoon pull a development version down do some fixes push those updates out and and you know set the site up ready for monday morning um so it's it's nice in the fact that because we're using the terminal to build our environment we are preparing our minds for a scenario where production can continue um you know in a structure that has our modules and our core always at the latest um always with security patches always with um the feature set of the current instance of dribble um and that that's that's a very powerful thought um one that um is different to to a lot of content management um stewardship that i've ever been involved in um in that we set these things up and and if we don't hear from the client we we don't do anything to their side so um and that can be problematic because the only time we hear from the client is of course when the site's hacked and and when when somebody's managed to take advantage of some um some security exploits so uh if we want to automate this then then using uh tools like composer like drush uh like the command line like uh bash like the the command line utility um we can we can end up automating this process for us inside rush there's uh other features like an internal server so in this case i'm going to run the server on a port that's not currently accessed or already in use and i'm gonna make that server available to anyone on any network interface anywhere across the internet so although we're on a firewall environment it doesn't really matter so if i localhost 809.0 i should get what is a fairly boring um completely uh theme stripped site now um when generating the site the site name has been generated the site slogan's been generated but also the administration password so i'm going to scroll right up to the top to find that password so username is admin password is blah blah so i've got to paste that code in and and get to my administration panel now this administration panel has no theme associated with it in fact my installation of drupal is in its minimal configuration the reason i've chosen minimal or partly from a compatibility issue in sort of maintaining the site going forward but the other point is that we want to engage a um a minimal permission set or or a minimal privilege or or a stance of least privilege in other words i don't want to install modules that i'm not going to use and i don't want to install um any feature sets that that might increase the surface of attack that this site would be exposed to so you'll see me throughout this video explicitly installing the module and then using the feature which is unusual because if if you did an installation what you're going to choose is the default installation which enables most of the core modules less the experimental and some of the sort of the lesser used ones um so this this video right off the bat is very different from many other videos about drupal and setting it up and running it um only because i i'm interested in the kind of work practices that we would need to have if if we wanted um to maintain a um a high level of management over um version control a high level of management over dev staging and production and and implement this ideal around continuous integration and continuous delivery so what i've done um at this moment in time is i've installed uh a few themes um but what i i also need to do is to um is to make sure that my environment is is set up so that it has correct access to to certain parts of of my environment um so i've had to sort of change the permissions of of some of my system and you'll see throughout the video the same situation occurs in that different parts or different operating systems might with different privilege do different things with my uh with my repository of of of system so in this case when i tried to do a composer update it wouldn't let me because it couldn't access the the uh files or the settings area um and when we start using things like um docker and kubernetes the each each orchestration system will then put other sort of um users and and permission levels on top of of the process so when we come back to dev we've got a sort of pseudo and we've got to sort of get some escalated privilege to make modifications to our environment but what i've done here because i initially downloaded 9.0 drupal which is i don't know 20 december i think 20 last year and now here we are in in march we want to be able to get the current latest version so what i've done is i've updated it to 914 but um it tells me in the um the report the the site report that the schema the database schema needs to be changed so i can use drush to do that and again i can can this process so every time we instantiate a production or a test or a staging site we can download the latest drupal we can automatically do a schema update on the database and we can start running with uh the current list version of everything and i i know this now because i i've looked at all the commands and i've noted them down and i'm sort of collecting a script an instantiation script that that i would use as a part of of um of the process anyone who's uses drupal for any period of time knows about clearing the case and again drush can do that so we can sort of just sort of press the up arrow and hit clear cache so if you're doing any theme theme work or you're doing any um any uh sort of entity relation work you know that the the cache needs to be cleared out at some predetermined times and you can you can um even sort of set up drush case clear or case rebuild as an activity that happens at midnight every night so so that that that could be pretty handy um so i've just uh started the uh inexorable process of sitting inside the uh administration console and i'm gonna start playing with um with the the admin panel to create entities and create routes and create views and create all of the things that a site would need and interdispersed with that i'm going to pull down from the odd module that i might need but i'm not going to pull the module in a way that we would traditionally do that you know i.e look at the website scroll down to the download option put the download in our module folder unzip the module no no no because we have a dependency manager what we can do is we can you know hit the hit the composer install functionality and say look i want this drupal module or this drupal theme or this drupal something to to be able to um to uh to install um composer just like any other command line utility has a a whole sort of plethora of um of options so we can update we can require we can initialize um we can you know revert back to previous versions we can remove bits and pieces but in this case what i've done is i've installed the um administration toolbar which adds drop-down menus so that i can drill and deep link directly into sort of the bowels of the admin panel and that that gives us a bit of an easier navigation to the places that we need to go inside the administration area and there are admin facing modules and then there's user facing modules and then there's themes and all kinds of bits and pieces and composer can be used to install all of those what's uh other what's good about composers is that it also stores a registry for the next time um it gets installed so when we push this project up to a repository we don't push all of the specific versions of the of the um component tree we actually leave that all blank so the only thing we're pushing up to uh to the get repository will be just the configuration changes that represent our um site so all of the core and all of the modules and all of the themes will be re-extracted with their latest version numbers at the date and the time that we need them so here i am i've installed an experimental theme called oliveira which meets the wcag 2.0 i think 2.0 double a standard you know so double a meaning um high contrast and you know keyboard navigable and you know text to speech compatible and and what have you so um and the first thing that i noticed is that um drupal by default allows us allows visitors to register so i want to immediately disable that feature now of course it might be useful for you to have that feature and for example there's a sort of an assignment that i set up for for students to do where we do have to have a registration on and we probably if we're going to put this in production is to have some kind of um capture some kind of i'm not i'm not a robot checkbox that you know some of the google authenticator type type utility has so that's a plug-in that we might go have to search for on the internet so that when people do registrations we don't we don't end up getting you know 30 000 bots all sort of registering a million accounts in the hope that you know our site gets hijacked so that um public registration process can be a um can be a bug bearer in itself um so i'm having a look at the uh the home page and uh 404 errors so if someone hits our site incorrectly we can redirect them off to home or if someone sort of wants to visit the home page we can we can give them a certain certain user experience but at this moment in time logged in as admin there is no content there are there is no uh ability to create content types until we install the module there's no ability for us to create taxonomies until we create the um the module so we've we've got to really build this uh content management system up from scratch and there are some some things missing so when you look at oliveiro um in other youtubes or you know when you've installed it and played with it yourself you'll see the search options and you'll see a number of extra blocks that represent other modules that haven't been installed in this particular instance and ultimately i'm not super interested in um in even sort of going there so to speak so i'm creating a new content type called policy and and based on the specification we we need to have these these policies go through a workflow these policies are initially uh published as draft so their initial state upon saving need need to be set in in a state where they can't be seen and then they need to go through a workflow of approval and when they've been out for long enough they'll get converted to an archive state and be obviously replaced with another with another piece of content so i'm removing all those options that says you know create a link automatically publish it but i am implementing uh version control so one of the reasons why drupal is is loved by governments and large bureaucracies is is really because of the audit trail that can be placed on a piece of content um so we can we can identify uh a forensic of everything that's happened to a piece of content over its life cycle um who edited when they edited what they edited and we can do reversions and we can do sort of rollbacks of that content depending on whether um you know we we have a rule for it um so i think that's sort of one of the um one of the core policies of many state and federal governments is is that there is some kind of history uh and some version control around our content um and it's ineffective if we use word documents where documents are a pain in that respect we have to rely on users to to manage their own documents and manage their own version control whereas in in a properly content managed or a proper document management system that that versioning is is done for us um so really what i'm doing here is is creating a piece of content um a specific content type and assuring myself that uh what we're doing is we're making sure that this policy um can't be created straight off the bat i'm sitting here as admin at the moment so i can i can sneak in as admin and just confirm in my mind that um that uh that i can create a piece of content the first concern i have obviously is is that i don't want the title of the document to be editable by a user and i'm going to need to install a module to resolve that so that the user will when they create a policy a policy number will be allocated such as you know something that has the year that the policy was instantiated you know maybe the policy category and then the node number that's associated with it so that there is this um uh nomenclature that's associated with uh the way in which a piece of content is created and and that that's possible it's just um a lot of little utility modules have been made by developers over the years to to achieve these these bespoke things that that um that clients have asked for and and drupal's particularly good at doing that um module creation is is not something that um you know non-programmers or or sort of new users would really want to adventure to but again have a look at drush because drush does allow you to create boilerplate modules um that you might be able to make superficial tweaks and therefore play in that in that that ball game so to speak um i'm having a quick look at um menus um and i'm making sure that my navigation module is enabled my date time is enabled my taxonomy is enabled so i'm going through now and i'm just making sure that i'm getting the modules that i need to make my um my my operating system do do what it should so that extension or that extensibility around um drupal is is its core feature so um drupal's generally made on an a kind of a an onion skin so to speak the underlying system is a as a low-level framework called symphony and that's why s-y-m-f-o-n-y no ph it's f um and that's probably just so that it can be searched on the internet in the in the way that it was written um and uh it's a very well used um development platform for for developers who even have a lower level view of of creating server-side applications used heavily for api development used heavily for sort of very bespoke applications but it turns out um applications like know page kit and uh joomla and drupal all use the uh symphony as their core so um uh and then we move up to drupal core itself which is is basically a um a skeleton for plug-ins to sit on top of so um and that allows um the team the drupal team to be able to be specialists in certain areas so you know there's there's uh content experts there's security experts there's logging experts there's theme experts and and there's an or a number of specialists that can have their own domain without stepping on each other's toes so to some extent features are quite fully flushed out in in these frameworks simply because of the extensibility of of of the environment so i'm still flushing around looking at different types of plugins that i want the one that i do need is is content moderation and workflows because i need to move my content from state to state from draft to published from published to archived and i also need um i also need the um the taxonomy and i may get to layout builder depending on sort of how we we go for time but layout builder is quite nice in that if we have a content type we can define the layout of all of the pieces of content in our content type and you may have noticed that when i built my content type policy i can add whatever fields that i want um and and that has a distinct advantage over many other content management systems that may only give you a title and a body and then store some metadata like author and date um with drupal you can set a content type to be any field you want or any number of fields or or any multiple values of that field or um or images or or even links to other pieces of content and and that's sort of the the beauty of of this environment is that it can sort of emulate um databases in a lot of ways so it's sort of a student this semester said uh this is um the configuration simulator 2021. um and i i had a good lol at that because it it's it's exactly true in that um instead of programmatically describing rules to allow us to create bespoke applications what we're essentially doing is going through a number of configuration stages to define the architecture in which end users will navigate their way through um the complexity of of of building an information system and that's that's sort of really where computing is at the moment is trying to to grope towards a um a level of of um abstraction such that we we don't have to write low-level code so you know in the 60s and 70s we wrote assembly and in the 70s and 80s we wrote you know 3gl or or you know procedural programming and then object orientated and and i think content management systems are just another type of of programming um but instead of programming with sort of specific logic or specific um [Music] structures what we're doing is we're graphically uh navigating through a set of um through a set of interface items so um and as such this video won't show any of the testing which would just it would just end up being sort of a four hour video uh and we don't we don't want to we don't want to waste too much time what i'm interested in is sort of taking you through a process so we've talked about what we're going to do in terms of a document management system we've installed drupal itself and now we're really trying to work out um how we can build pieces of content together and structure them together so if you look across the top we've created pieces of content in a certain structure that have a certain look with a set of modules that provide those features so in in many different instances all i'm doing is is having a look closely at what are the features that i need so what's missing not only dates and times but also uh graphical editing so there's a javascript type editor called the ck editor it used to be fck editor but obviously people did have problems pronouncing that so they took the f out but that ck editor gives us a sort of a beautiful interface to um to allow us to set bold and italic and layout tables and set colors for our text the interesting thing about drupal though is is that it uses a fairly restrictive set of rules around what content can be created so um the text formatting fits within sort of a very sort of refined set of html elements so for example you might not be able to put script tags in or even php tags because that would represent sort of a certain security risk so we we do have restricted html in creating content itself and will give users the right to maybe drop images in layout sort of text but but certainly not there'd be some validation in in what goes into those fields to ensure that we don't get sort of cross-site scripting or um sort of uh any server-side code being executed as a result of trying to render some of our text so in a lot of ways drupal gives us a pretty a pretty clean sort of environment to work from uh and our minds are open to the challenge of providing something that is is bespoke to the client's needs um the the flip side of that coin is obviously drupal does nothing out of the box like it's it's completely ill-configured to do anything and and quite a lot of forum time has been spent talking about how can we make drupal more applicable because when you look at wordpress for example its functionality is is writ large as soon as you uninstall as soon as you install that and unzip that and start running it on a server it's it's it's pretty damn clear that it's a blocking platform to a large extent the joomla followers are the same in that it's pretty damn clear um that joomla has um a page building uh sort of a fairly free structure for for structuring pages and um you know of the three um drupal joomla in wordpress uh drupal fits into the sort of the also ran category it's sort of falling away a little bit in terms of its its utilization and to some extent that's a that's a blight on on the drupal team itself for focusing their efforts towards what i would consider a corporate area or a um a government client um so quite often when you talk to some of the sales people that um you know have a lot of large-scale contracts they don't call drupal they call it gov cms or they call it whatever distribution or whatever brand that they've sold to whatever government or corporate client that they're they're pushing into so um drupal in itself is is is sort of suffering from a a little bit of fractionalization in the market because it tends to be seen as a as a number of different things to a number of different users um so i don't think it's going to disappear any time soon but but certainly it its use cases will start to restrict until we can get sort of a nice wizard feature to sort of instantiate for um you know non-profits or to instantiate a a system for shopping carts or instantiate a system for um in this case here you know some kind of uh you know moderated content process or newspaper process or something like that um so i'm still playing with content types and i'm still sort of confirming that that there is the structure that that it needs to be and you can you can see that there's a little drop down menu um for changing the content type so the summary is in just plain text but the body has been set up in such a way that you can edit um html so there is like bold and italic and creating a link and creating a bulleted list quotations and and inserting images very restrictive in its utilization so you can go into the configuration and actually update the editors themselves and then extend the way in which the editor will work so you can end up sort of putting a few more things into that editor to make it a little bit more powerful what we're looking at here and one of the things that happens when we change themes is some of our blocks get a little bit messed up the way in which um drupal knows about where things should sit so for example that powered by drupal thing usually lives in the footer but when you reset the theme sometimes it'll go into the header instead and what i'm doing here essentially is is creating a new block and then sort of defining a a new role for that block putting some new content in that static block um and then sending it to the footer so that we end up having so instead of powered by drupal and a little tiny drupal icon we've got something that might be more befitting the um the footer of of a government side so we can end up building what is a template both of style and of substance so the block layout system is a way in which we change the substance we define either static pieces of content or dynamic in the form of navigation or in the form of views or in the form of content editing or or even the layout of a policy but what i'm what i'm having a play with here is is just sort of looking at the different ways in which we can set blog set blocks up so that we can create our own custom blocks and that was the plug-in again a plug-in that wasn't installed one of the reasons i like to start from an unconfigured drupal instance is i note that if if you do go to the fully configured drupal um it's hard to turn off those core modules like once they're installed once they're turned on once there are things that depend on those modules i.e uh pieces of content you've created or navigation you've created you can't un uninstall them when you've finished your dev processes in that you're you're now ready to go to production so it's kind of nice in that what you do is you build up this bespoke version of drupal with only the things that are needed at that time so you can see throughout this video i'm interdispersing the visitation to the extend menu going to modules and installing the the piece that i need at the time that i need it certainly a pain if you're learning how to use drupal from the beginning because you might not know what features are available if they weren't already turned on for you so there's three modes that you can install drupal at if you if you just choose the um the stock standard drupal 9x 91x there's the minimal which i've done there's the standard which contains pretty much all of the core modules enabled and then there's a demo mode which um creates a lot of content and configures that content and has essentially a working site for you to have a look at and pull apart and i do recommend that you do installations that have these example sites on them in fact go to the distribution section of drupal.org and see what govcms looks like and see what what the drupal commerce or the commerce guys have put together for drupal commerce because these are spins of the drupal core in such a way that they will work for certain use cases it would be really nice to put that in an installation wizard so instead of three options during install you can choose one of ten and you can immediately configure your drupal site for a very specific purpose and that in my mind would sort of increase the um the utilization or the the understanding of of what drupal is useful for um i went to the drupal meet up um in fact um and it was was stated to me that uh because i pointed out that uh on um what was it i think it was w3schools survey um you know every year there's a developer survey so a number of like github do a developer survey and and w3schools does a developer survey and anyway one of them said uh what is your most liked and most loathed and i pointed out at the the drupal conference the the meetup um that drupal appears very high on the most loathed frameworks of of um of web developers and he pointed out he said look i've got an i've got an alternative graph to show you and he showed one of where um he compared all of the the the corporate type content management systems and and those that had experience with them those that had to use them in their professional lives tended to sort of highly rate this platform after they got to know it um and again if i bring another student up um you know week one i hate drupal drupal's the worst and then week four week five i'm starting to like it um so you know there's a little bit of you know once you understand what it can do for you once you have an idea for for its advantages it it starts to become something that that you might um use as your your development platform this is the gateway drug for non-programmers to do what are programming related activities and and i think that's an important um distinction to make i spent a couple of years working for a startup that that tried to do exactly that tried to build a system an information system where you'd just drag and drop drag and drop and i think drupal does that pretty well like it it's pretty much a it's a framework without any functionality from from the first moment and you've got to spend a day to set it up in such a way that would meet a specific client requirement the only difficulty is you know it's hard to get started when you have to get started so i'm here having a bit of a play with the ck editor um and ck editor it looks like it's gimped out of the box so it is possible to get a number of editors so again the um the uh extensible nature of this this environment um ck editor there might be three or four ck editor modules that that allow you to do a number of different different configurations with um with the environment this one looks a little bit minimal but it does reflect the fact that minimal html is allowed for for end users and it tries to sort of make you need what is a minimal set of tools to layout content um i noticed that uh what do you call it wordpress uses um gutenberg now so version five of wordpress has has a a different style editor which which to my mind sort of harkens to a bit more of a modern set of ideals this one's a little bit word orientated but when you look at gutenberg it's a little bit more block orientated in that what you're doing is you're dropping blocks that have three columns or you're dropping a table or you're dropping um you know different different pieces of interactivity into the content whereas uh what wordpress what drupal is is more of a blocks orientated the functionality hides in blocks not the content the content is fairly static um whereas wordpress what we do is we install the module and then we say where where does that functionality sit within the content so it's somewhat of a a different different way of thinking so if you're coming from wordpress and you've been given a drupal job you you've got to think the way drupal thinks and that is probably i don't know in in some ways a bit more of a traditionalist ideal in that you you need to architect the page as a whole um and think of content as static um the actual pieces of content itself so you end up sort of using page builder to define the the interactive elements you want in the form of a block layout um but um the data flow uh the workflow the permission system is all so much more granular than wordpress so i don't want to make this a big wordpress you know pylon but um wordpress has five user types and drupal has any one of an unlimited number of of roles that you can set with granular permissions across those roles there are ways of installing modules for wordpress to make those five user types do granular things but out of the box you you know what wordpress is wordpress does one thing very well and and and quite often for most of the use cases where i've seen wordpress it's perfect it's perfect for um sites that you know have have a static kind of uh character about it but in in some cases you may have to you know define a specific process and quite often customers are very um [Music] very clear about how they want things to work uh and to some extent uh drupal can accommodate those those work practices quite quite well what am i doing here i'm i'm adding the taxonomies uh which represents the categories of policy that i want so i'm coming up with some example categories for a government organization that might or a local government organization that might have departments and therefore each department might have their own category of of content um or category of policy and what's cute about uh taxonomies is they are hierarchical so you can have a road work section but you know the highway team and the uh urban team can have their two policies or you know when you're looking at transport you can look at public transport and commercial transport and private transport so there may be policies that sort of break down on those those grounds and therefore you can you can break things out in in in a hierarchical structure um when drupal comes out of the box it comes out of the box with bartik which is a theme that doesn't very well support the sub-menu and the sub-sub-menu very well so when you're building taxonomies and when we go to using those taxonomies i use this taxonomy in two ways i use it once for my content type so i'm essentially doing that right now i've gone to the policy and i've said look what i want is i want the policy category to be one of the options when you create a new policy so you'll be deciding when you create the policy what category that policy sits under the other thing that i want to use taxonomies for is for navigation so that the menu system reflects all of the different policy categories that we have i have to change the form view so i add the uh i add the field i also change the field entry view so that it produces a drop down and i can move or change the order of the way in which that content will render in a number of different ways so um within drupal you can create different different views for your content so you can create a view that would go into so you can create a view of content that would go into a listing or you can sort of have a a brief uh version of that content or a complete version of that content but as we scroll down and have a look at the um you know filling out one piece of content what you see here right down the bottom is policy category and that's that drop down that we created so we created the taxonomy we related the taxonomy in to the content itself such that the content can reflect which taxonomy category this relates to very powerful stuff um we can go one step further and in a previous video that that um you know drupal 8 video i did if you wanted to scroll back to it talks about creating a taxonomy or a special type of taxonomy which is a listing of content that isn't that can be embedded in another piece of content so in that case it was of the batch of cupcakes that you tasted and do a survey on that particular batch so we we had two pieces of content a batch and a survey and the survey was based on a batch which you know again taxonomy or or something more dynamic which represents the title of the the batch that occurred i don't like that pink um it's one thing that i would probably change pretty quickly in this particular theme is that the things that are in draft mode have a certain color and that's fine but i'd go with a grey myself or or maybe even set a background that says draft that actually sort of has the watermark behind it that says draft so it's made clear especially in policy land you you want to make sure that everyone knows that the the document that we're looking at is in draft stage um so you know the the client would certainly want that kind of stuff and and um you know in the theming part of the process it would be be something that worth doing so i'm having a fiddle with the content type itself and and moving pieces of content or fields themselves in in certain order so that they look a little bit better what i'm grappling with i think is where some of the blocks are being laid out in this theme because when you reset from bartik to oliveiro uh it ends up putting a lot of your blocks in the header when they should be distributed throughout onto the content itself so you've got to do a little bit of cleanup work when um when you're you switch from theme to theme so just bear that in mind that make sure you have lots of examples of content before you begin your theming such that you can see pretty much every type of of content that you need to touch with your css in order to make it look beautiful i i don't mind oliveiro it does look more modern certainly more modern than um than bartik does uh it it's still i don't like the the borders around active but it's there for accessibility you don't have any doubt that you're reading that your focus is on a particular field and that that's beautiful in some way but you know a bit bit harsh in others i'd probably prefer to use color than than line um i'm fighting the the system because i noticed that again the workflow is designed in such a way as to not allow you to go to published mode and and that button that that previews is not technically a save button so there seems to be a bit of a bug either in the theme um possibly the way i've i've set up my blocks that the the save button disappears i haven't quite worked out why that that is but certainly something that that once we get into the theming part of things i could sort of find out whether it's in a hidden state and and not not actually use user viewable the other point is that certainly administrator is not going to be creating content so i'd need to log in as an identified user that is someone who's allowed to create policies and i'd log in as an identified user that is allowed to [Music] move policies from draft to publish so certainly i'm not testing this in the way that it should be tested and as a result i'm not theming this in a way that it should be themed because we're not going to theme the um the admin panel the admin panel isn't isn't our focus and what you see in a lot of these these screens here is not the uh oliveira theme it it's it's actually the uh admin theme that that that is listed here so what i'm doing here now is i'm going through and identifying the two roles author and approver and defining who's allowed to do what so again one of the um the batman features of this content management system is i can be very granular about how pieces of content are allowed to be massaged by whom and what i'm doing is i'm giving approver a lot more leeway to do things than i am the author so the author can create content they may be able to edit their own content but they're certainly not allowed to delete only the approver can delete so um in again government situations nothing should be deleted um everything should go through a defined process of archiving so we should always have some audit trail of what happened it's just like facebook or ebay you know there's no way of of getting rid of your facebook profile even when you delete your account even if you're in the eu um so you you end up sort of at least in in drupal and being able to say okay yeah let's make sure that we can view revisions make sure that we can um you know uh see what um what the overview page looks like um so anonymous user is someone who is a user of the system but obviously a special type of user that has not authenticated why isn't admin there admin used to be there it was a bit weird and admin was there all the time but you had no ability to turn on or off the features of admin so obviously the devs at some point between eight and nine of drupal decided that what's the use of having that admin column if they can do any everything anyway um so i'm adding a workflow here that workflow is necessary um so i've been been alluding to this for a while so under the configuration tab there is a content moderation section so what there's three parts to this um this moderation uh there is the states that the content can go through there are the transitions that can be made through these states and thirdly there is the content that can be manipulated by that workflow so in this case what i'm doing is is i'm defining a transition from published to archived and i have to give a name to that transition and you'll find that once this workflow has been set up we'll need to go back to permissions to permiss the right roles to move that content between these transitions right so it's not the states themselves that people have permission to obviously you know we can set that but in in our playing of this process what we're really interested in is who can move the content from state x to state y and what i'm really doing here is i'm locking it down good and hard i'm reducing the options for people to move to different states so you know we can't move back to draft from published we can only move to archived and i saw that the other day when i was editing some system for sort of personal profile information when i edited my profile that profile item that i edited um went to archive and was recreated as new so in other words they couldn't do any kind of version control on the content so they wrote they wrote a system that ended up duplicating that piece of content so that the the original content could remain in some form so i've gone right back to my people menu and having a look at the permissions and you can see here policy workflow so there's three specific um things that are related to moving the policy from one state to another so and i think i've got them the wrong way around yeah i have i should have the ticks in a different place um yeah the two people that are watching this video will probably probably not notice that um okay so yeah so there we go we we can we can save the permissions on this on this environment so magic happens so we're we're getting pretty close to one and a half hours and we're still oh no yeah yeah oh one hour um and we still got another hour to go so what i'm going to look at here is installing another module in fact uh at the last brisbane drupal meetup um the developer of this plugin uh demonstrated its features and i thought oh my gosh this is exactly what i need for the policy database or the policy system because uh what we need is some kind of an index value automatically inserted into our content type so it was very fortuitous that um a local developer here in brisbane vladimir who convenes the drupal meetup um actually is a contributor of this particular module and obviously when you go through them the modules section there's thousands of these sort of fairly low download um fairly small bespoke modules that achieve some very specific business process that no one except maybe 30 people in the world need at any point in time during the life cycle of their development but nonetheless um it's something that i want to install now and you might have noticed that because my development environment had some kind of a root privilege when they created the development modules here my composer doesn't have permission to write to that modules folder so what i'm going to do is i'm going to cheat i'm going to give composer escalated privileges it's going to nag me and say you better not do this it's not a great idea but you know i'm getting the job done so to speak um if i wanted to do this right i'd probably run it in a container but i would have to shell into that container and operate it as as a sort of an interactive terminal there so i don't i don't really want to do that i'd prefer just to sort of push on um and set things up properly uh so i've installed this module this um entity um label module but it it mentioned in the documentation that if you had token installed then it could dig into some of the features of token i don't quite know how it digs into features of token but just in case it crashes on its face i'll install this module and and confirm in my mind um whether it represents some use for me because it's a contributed module and if i don't implement with it then i should be able to uninstall that module or even just remove it from my um vendor dot json um file and and and stop it from being a part of the next build so um notice that what i'm doing are two things i'm saying please install composer with um on the left the framework drupal and on the right the module that i'm after and i want to be explicit because there may be four or five projects that are of token type so i want to be very clear about what kind of token i want to install so now when i check my contrib folder inside modules i now have four modules and and dipping down to the extend area i should see now this um token uh module as well as the um the entity um yeah got to type it right the entity label which uh adds an extra tab when i'm creating my content types to denote in that specific content type that i want one of my entities of content type to become an automated label so i end up getting a value automatically allocated and that that suits the the use case here where every policy must have a policy number now i would make the assumption that policy number needs to be you know probably the date that was created probably the category that it relates to probably an index number for that category and then maybe even you know uh some kind of um you know prefix or suffix um but at this stage i'm only going to use this entity label to mash together the content type policy and the um node id which is the the machine allocated number that's given to the piece of content that's created so when i um initially create this piece of content what's going to happen once i publish it is the title will be turned into this index value and it will be you know policy number blah blah instead of um you know instead of a name that i pick so at the moment i haven't actually saved this piece of content it's still in draft format i've got to go back to editing and scroll down and actually save that there's a strange bug in oliveiro i think it's hiding a certain piece of content but you can see there this is the third piece of content that i put in and it's of type policy so the title has now been given some kind of an entity structure that is of my uh of my desire or my making we move on to dates now and out of the box uh drupal speaks american dates which is month day year doesn't speak european dates and doesn't speak australian dates it it um it needs to be configured to communicate a certain date format i'm not sure whether um well obviously php based applications can't dig into the the local environment of the browser that's using it um it would be nice to sort of you know write a plugin that introspects the client browser's locale and then renders the write date format for them but in this case it would probably you know be a bit of searching for the right module so my my general modus operandi and it's not a big deal it's just just to go into the date format and reformat for australian dates or european dates so europeans like year month day americans like month day year and australians and maybe a few other countries you could yell out in the comments for the two other countries that might do it with day month year um so we go smallest to biggest uh most databases will store what are called iso dates uh which are year month day hour minute second which becomes something that can be ordered um so you know when when you you have um you know your orders of precedence set up correctly it's not hard for um for a database to to do orderings correctly so uh if if there was a referendum in this country the change date format i'd be pro year month day um so that's sort of pretty much uh getting towards the end of our configuration experience but what i would like to do is is to move on to thinking about the way in which we theme things or the way in which drupal is set up for um restructuring content we did a little exercise in the class yesterday where we took um two core themes one was oliveiro and the other one was called classy and when i look at all of the examples um quite often we're looking at um developing a sub theme based on on um on classy so classy is a pretty common sub theme that that's there and we can use that as a as a way of of structuring um uh a theme from scratch from from absolutely no style whatsoever so if you if you sub theme straight from classy what you're doing is you're getting no style zero style none and i've worked in a few environments where the devs are like that's that's the world i want to live in where i build the theme up from scratch and and you know power to them but if you can find a theme that you like and then make light tweaks to it that might save you a hell of a lot of time but i think i'm jumping the gun because what i've got in this video here is a little process of of actually using the taxonomy in a different way um so if you remember we set up taxonomy so that we could choose the category of policy that we needed but again a little tiny bespoke module that maybe only three people have used in the last 12 months interesting one in that what you can do is you can set this guy up so that the the menu system will reflect uh what you've got in your taxonomy and that menu system will automatically link to a view and a view is a very specific type of functionality in that a view can be set up to show a listing of pieces of content so what we can do is we can set up a view that says show me category x show me category y show me category zed and each one of those taxonomies is given some kind of an index number so index one might be roads index 2 might be highways index 3 might be public transport and each one of those indexes can be linked to a piece of content or a view specifically what i'm doing here is is trying to get some idea as to what these modules or these contributed modules are doing because there's an inbuilt help system so if you install the module that shows in build help it creates a new menu on the far right and it'll give you little bits little tidbits to help you understand what's going on and guess what taxonomy menu gives you a one sentence description taxonomy menu module transforms your text mononomy vocabularies into menus well thanks for that i really appreciate it um i do have to go back to the module description on drupal.org to try to find out how to use it so you might find me tabbing off to that to sort of understand how i need to structure my view in order for that taxonomy menu to work successfully so what i'm essentially doing is i'm saying hey make the taxonomies the navigation make the taxonomies the choice that you have for each policy but also the destination for each taxonomy menu needs to lead to a view that will show the number the taxonomy number as a part of its view and you can see here there is already a view set up for exactly that um and i don't want to use that because it's not actually showing um the actual content it's not showing the the policy itself so i need to disable this view because it's taking the url that i need for actually rendering from the menu system itself and i'm going to create a brand new view and you can think of a view as a query a query of the data the data being the content so what i'm doing is i'm saying i need a new taxonomy view it's going to look at content it's going to find the policy content type i'll it'll be a page and what i need to do is i need to pass it a variable that represents the taxonomy id so i'm going to say the taxonomy id will be blah the taxonomy id will be blah so i need to grab what essentially is um sort of like a hierarchy which is taxonomy term and then i use the percent sign to say i'm going to substitute whatever the percent is for um a value which represents the taxonomy number at the time and that will be a url parameter so that url parameter is going to be read by the view and then the right content type is going to be delivered so here we are i'm going to make things a little bit broader so i'm going to remove one of the filter criteria that says it must be published that's so that if you're logged in you can see both published and unpublished content you can see the url but i i have to change the contextual filter so there's two types of filters there's a filter that represents how the view in itself is going to work but then there's a filter on what the url needs to look like so the specified field represents the url parameter and i'm associating that with the um category id from uh policy category um so it's it's funny because views is is dense in itself it's probably worth a two-hour video all on its own um and maybe you might find one or two youtube videos that might really dig into the complexities of this it's extremely powerful and if you think computers do three things you know they take input content types they process that input probably cron jobs or um or structure calculations or what have you and then they produce output and in in drupal's case what we're doing is we're we're kind of merging the processing and output a little bit in the form of views because we're we're processing our information and we're filting filtering our information in such a way that the views that were entered or the content that was entered gets reiterated back to us in a different form so we're not technically doing you know processing as in bitcoin mining or you know weather forecasting we're we're really just reformatting information we're we're taking information in and we're then providing that information in a different form and that's essentially what what's happening here is is that i have a menuing system and that menu system is linking look at the url is linking to the taxonomy id which is embedded into the view that shows the view shows the content types that have that taxonomy term so there's a there's like the circle of life that's going around here in that um that that in that taxonomy is the um you know is the center of the of the circle it's the one that's uh it's orchestrating how all of those content types are are interrelating with each other so it's a very powerful system if you can use the right combination of modules and the right combination of of um of uh architecture of your own own machination so we've gone back to the command line lucky yes and we're going on the home stretch so the last um where are we now we're at five last 40 odd minutes 45 minutes is actually deployment so um if you're not interested in doing deployment then then maybe oh hold on i lie we're actually doing the theme so we're in here talking about themes i've skipped the gun um so i'm using brush here to create a subtheme uh and um as i pointed out before there are um themes in the core there's probably about five or six themes in the core of drupal itself and there's only two or three that are are shown so you've got bartek which is the default you've got seven which is the admin theme and then you've got a bunch of experimental themes that have been placed on top of those one experimental theme is oliveiro and what i'm doing here is i'm cutting back olive arrows so that it just allows me to hack in some extra css on top of the styles that are already there very risky activity at least taking what essentially is a complete working set of theme and then trying to weave my architecture through it pretty challenging stuff because you end up really having to understand how that theme was put together and what the rules are for that theme a theme is made up of a number of pieces css is only one of a number there's javascript there is what i called twig templates and there's a combination of php and html that are wound together i don't recommend people dick with the templates early in the in the development process it's it's only when there's some intractable piece of content that they've got to insert or get rid of from from the environment that you can't do through the admin interface that you you can't switch on and off with the checkbox um you end up sort of digging into some of the some of the ways in which um templates work but what i've done is i've set up this oliveira theme in such a way that it only becomes uh the last style sheet that gets um that that gets uh passed by the um by the browser and what i'm i'm doing here or what has happened here is that like i pointed out before when you change your theme the uh the blocks start to go awry they start to move about the place so you can see the title has moved into the header and i need to pull that back down to body um and uh footers moved up to header and it needs to be sort of moved down to footer so i'm just moving a couple of these these blocks back to where they should go so that they don't they don't look so so messed up and that's just a function of the fact that you can have a unique block layout per theme because if you look at the top of this page this blocks page you've got a bunch of tabs some of the tabs relate or relate well each tab relates to its own theme um and you can see there you you know which theme is active because it's the first one on the list so now that i've got um the theme installed and i've changed some of the blocks i'm just you know configuring out the picture and you can see here there's my one piece of content and the header is moved down to the body and at this point i can go in and i can edit some of that css so that i can just prove to myself that this sub theme is actually working i think if you're doing some serious amount of modification of this theme be warned when it says experimental what it means is that the developers have told you that they're going to make breaking changes i'd feel comfortable about the names of the classes that they're using i'd feel fairly comfortable about just editing css but you know things might go awry from version to version and yeah so all i'm doing here is i'm using dev tools to inspect and find the exact class that represents the page title and then i'm confirming in my mind that i've targeted the right class saved it off and i hit the refresh key my hope is that it'll immediately go to the color that it should now it doesn't always do that and that's why using the case rebuild option either through drush or through admin performance menu will give us that that sort of option to to see the latest the other is to turn off caching in your browser um so just bear that in mind that you're you're going to have uh automatic caching inside your environment um screw with you and make your life a little bit more difficult where are we now uh oh i had a problem in that um i'm still left with the system generated password which i've long since forgotten and this is a fairly common problem and and you know the hackers amongst us might sort of be able to sort of get our ears pricked up on this passwords are encrypted uniquely per drupal instance so i can't take a password that was generated on drupal site a from the database and then paste it into drupal site b and expect me to be able to get into the site what i technically need to do is i need to make use of what i think are some characteristics of the site so every site creates a unique ssid or a session id and that is used as a seed for password creation so what i have to do is i have to use drush to generate our password now you don't have to use drush if you go into drupal core there's a scripts folder and inside the scripts folder it can do the same it can generate a password that you cut and paste out of the terminal and then drop in the database manually drush is a little bit more friendly in that it will manipulate the database on my behalf which is is sort of a little bit more friendly and it might be something that you do as a result of instantiating in production you might have a little drush script that says resets the password to some a password that nobody knows so not even um you know an ex-employee can sort of you know mess with the production side um and that um you you end up with the production site being sort of immutable in some way and that you can only sort of make modifications to a production site if it goes through a proper ci cd process that is it's it it starts at a dev we make our changes we push the staging we check those state those those changes are okay and only then do we move it to production not going to deal with ci cd today what we are going to do is we are going to push up to a repository because um quite often version control is is the savior of everyone's ass and again very few wordpress sites very few cpanel sites that i go to have people actually engaging in some you know quality backup regime so um what i'm doing is i've created a repository on github and i'll include this repository in the description of this video so that you can hit it and and you know do the things that i'm doing here in this video um and what i've done is i've sort of described all the things that i want git to ignore okay so the things that git are going to ignore will be the vendor folder uh we'll ignore the web core it will ignore um the modules folder and i've told it to ignore the [Music] env file because the env file is going to contain environment variables and what i'm doing as a part of leading to production is to d passwordify everything because what you notice there when i look in settings.php of drupal i've um hand coded a password in there or the install installer has hand coded a password in there and passwords embedded either on server code passwords embedded in any repository are generally considered bad practice so what what i'd like to do is i'd like to d passwordify um the anything that's related to this project what i end up doing is putting those passwords in an env file which is ignored by git and and that env file is something that i would have to hand code for each um destination so you'll you'll find that in certain sort of version control systems or certain sort of ci cd pipelines there'll be an env dev an env staging and an env production and each env will contain the credentials for you know the production database and the credentials for the development um staging platform so because i've instantiated or i've started a new repository here there's a procedure that i need to go through in pushing um all of the code that you see here up to up to its repository so i'm committing um all of the files that related those things that that i need so you can see here i was playing with classy as a sub theme um so i'm going to push up you know all of the code that relates to everything that i've done in the last couple of days with regards to this repository and i'm going to then send push push all of that content straight up to the server and that's going to take a little bit of time i think i've sped it up so i've sort of sped up the video to 400 times speed so this is not the speed of of my internet at home it probably took me a little bit longer than a minute and a half in fact maybe i haven't sped it up so i i have to i have to speak a little bit more um about this this get process most devs use git and the reason they use git is because we have a history of all of the things that happen since the inception of that particular project in more complex environments we might have uh branches we might have like a core branch which represents all the development we were we've done on it but we may have some branches for client a and a branch for client b and a branch for client c which represents different um historical changes that were made specifically for one client so i i've used main here as the main branch but you know we we might have um a beta 2.0 branch or a um you know a production branch or something like that and and again the ci cd pipeline would look at the production branch for production code or they'd look at the staging branch for staging code um so essentially what we're doing here is we're taking everything except for um the libraries that composer is able to pick up from third-party locations so essentially the database itself um any files that i might have uploaded um any uh theming that i might have done uh any pdfs or images that might have been that might have been embedded onto or into my content managed environment so you can see here although i have composer json and composer lock i do not have the vendor folder the vendor folder is completely missing and it's only when i say composer update will that vendor folder re-initialize and core will be recreated modules will be recreated um contributed themes will be recreated my custom themes are still there so and the password to my database actually is there so if we scroll right to the end you'll see that username that password is there and this this is the cardinal sin of deployment in in in git repositories um so i'm committing the offense that should never be committed it's funny like um everyone that i talk to says this is the worst thing ever but when i ask them how they resolve it it's it's like the secret source it's like no one wants to really tell me what their technique is because it's very specific to the production environments that they're using so if you're using aws it might be you know procedure a if you're using google cloud it might be procedure b if you're using cpanel it might be procedure c so so each each environment or even things like um you know get um was it bitbucket and gitlab um they have special pipelines and special secrets files that you you put stuff in but what i've i've heard or what i've what i've played with in most cases is this.env file which is what we want to deal with now the env file will be the thing that helps us instantiate our database and set permissions on the database it will help us instantiate our drupal instance and get drupal to point at exactly the same database that was created elsewhere so um yeah as you can see we're heading towards deployment land our first step is to is to push code up to a repository and that just means that it's in this central location where dev staging and production can all access but now that i have um a repository i need to test to make sure i can sort of reconstitute my content management system with what i've pushed up to that repository so before i delete any code from my file system i really need to go through a process of of rehydrating my my drupal instance back to its original form and i'm going to do that with docker so um probably the title and the description of of this video might have attracted you because i do mention docker here so here we are at uh where are we we're one hour 20 into the video of the two hour video and and we're probably going to spend the last half hour dealing with the the docker portions of things so my first job essentially is to create a dockerfile and what that dockerfile or docker compose file does is it describes the network in which all of my services will exist right now network what network well when you're building microservices what you're building are individual pieces that do one thing and one thing only so the database needs to live in its own container and do one thing drupal itself with its php and its php interpreter needs to be in its own container and do one thing only i'll make a third container just to help me assure myself that my database is working successfully so for development purposes only i'm going to make a third container and that one's called the phpmyadmin you may have used phpmyadmin to instantiate your database and you may have used phpmyadmin to backup your database in the cicd world that interaction is not recommended because again a human's involved in that and we want to take humans out of the process if we're developers what we want to do is we want to develop a pipeline that takes care of itself so this particular process is is an attempt to try to sort of create what essentially is an environment that will work on all of our in on all of our states on our staging in our production and our dev so in theory what i'm testing in dev should work exactly the same way in production so there will be no doubts no questions no no concerns because the libraries and the and the um and the environment will be the same on all platforms so if we break this guy down what i've got um and you look at the lines that that are indented um from the from the top it's the version of um it's the version of of um docker compose that i'm creating here so version 3.1 is my my version so over the last sort of five years of docker there's been a few different versions of the way in which we declare these files then our list services and services are high-level things that i'm going to do those services represent um the um the individual containers that contain the functionality that i want so db php phpmyadmin and drupal all represent three containers my indentation's not quite right i've got to move ports in a little bit and then each one has its own sort of little bits of knowledge so uh the common things amongst them are image container name restart and some of them have volumes but the image represents the type of container that i want to create so i want to create a mysql container that just has the database and i want to create a drupal container that just has drupal i want to create a phpmyadmin container that just has phpmyadmin now i'm getting a little bit tricky and what i'm doing is i'm exposing the container to my development environment so i'm saying hey look the sql folder that represents the dump of the database i want to push that into the database container and the drupal site um i want to have a volume that pushes my drupal site into the drupal container um and if you note there the database does not have any exposition outside the container so i'm not exposing any ports to the outside world from that container the only way anyone's going to be able to access access that container is from within this network from in this network that has three hosts a host that is the gov database a host that is the gov db admin and a host that is the gov interface or the container name and i'm finally working out this all important uh env file and i'm incorporating environment variables that each container has and i'm linking them with the env file so the env file is going to have a dbeu dbhdbp and a db and each one of those represents one of the four things that i need uh each container to know about each other so the database needs to be known by phpmyadmin and the database needs to be known by drupal so essentially when i create this file what i'm doing is i'm declaring all of the features that i want the micro service to inhabit i need to do some weird stuff with the drupal container because if you remember when i pushed up into git i didn't include any of the composer libraries so i've got to tell the drupal container when it wakes up hey go out to the internet grab all of the libraries that we need delete whatever whatever is in the html file to the public html folder and then put my drupal instance there um so there is a little bit of sort of upon instantiation please do these three things so um what i'm going to do is i'm going to attempt to build uh this docker instance and i'm going to build it badly um in other words i might even forget to include this env file um so what i've i i know i have to do and i mentioned this before is that i have to go down into my php and absolutely eradicate any of these specific users and specific passwords and i'm removing them from the environment completely by replacing them with the env super global in php so star dollar.underscore.env [Music] in php terms of superglobal so you can access things about the request and the response object you can access session information you can access server information but you can also access the environmental variables that were pushed into it from in this case that docker compose file so what i'm doing here is just making sure that i'm using all of the the specific names that are exposed to this container so that we can see the database name the database username the database password and in the last one here the host name and the hostname uh isn't localhost so in most cases you'll you'll know that the database lives right next to the web server so you're always saying eight nine no three zero six sorry um no no no not not in the microservices architecture you you've got your database living in a different location so we we define them by their host names um so each each machine has it has a name on on that network so i'm going to try and do a build but it's going to tell me hey you haven't set your environment variables yet bugger i go but let me confirm let me confirm what i did wrong by looking at the config file and what this does is it prints out a version of the config file that has been interpreted by docker compose and you can see here there's my configuration file and all my environment variables are empty i've stuffed up so i need to go back to the start and i need to say oh yeah you're right silly me i'll grab this information again and i'll create my dot env file how does how does docker compose know about dot env i don't know how it knows about env it just knows it it's like some omnipotent god it looks for dot env and it says yeah okay no problem u1 env i'll find env um it's sort of the standard um for every type of dev the environment so when i look at react apps or when i look at symphony apps or you know pretty much any web app this dot env file is is pretty much a common place to hide secrets so what i'm doing is i'm putting some weak username and weak passwords uh into this structure but it may also be a machine generated thing that comes out of your um you know your ci cd process you know your um your bit bucket process or your git lamp process or even github actions you can set up actions to to end up writing these files with things that come directly from your cloud secrets file so now that i run this you can see that the username and the password and the database and the host name are all there then they should be in the right places and i should be able to run docker build docker run docker up docker down docker rm um so it it should look at this file and and then pre-populate each one of those containers with the credentials so that each container knows about its brethren um so what have i done i've said docker composer so here i'm still on my local machine and i'm still working with um local resources of this machine um but the point that i want to make is that if i use something like docker what i'm doing essentially is i'm finding this common ground between what happens in the cloud and what happens on my machine so i end up having the same environment in both cases and i sped this up by a thousand percent because my internet connection sucks so please don't assume that i can move um you know what essentially is a a gigabyte of data that quickly um later on we'll we'll do the same process inside the google cloud console and i think it's just a little bit faster than that so um if you have to do a lot of container work sometimes working in the data center through a terminal makes a lot of sense because your iterations are much faster so i'm going to test this so i'll type localhost and then triple nine and i should get to the database and you can see the database name is exactly the name that i gave it in that docker compose file everything is sweet and cool at least from the databases perspective i'm still waiting for the um drupal container to arc up and pick up all of the composer libraries that it needs so it goes out and it it calls composer so how many times today have we have we called um composer a very busy site um hopefully it's got its um you know uh um different versions of the site in different different parts of the world so cdn network is set up correctly because you know there are petabytes of data that are moved in and out of docker hub and petabytes that npm and and um and composer use and i did notice with the um i think it was the admin menu or no the taxonomy menu actually didn't go to the repository and you can see here my container the container that i created for drupal doesn't have git installed and what's happening is that one of my modules which one is it it's the taxonomy menu is not actually using composer's um internal repository it's been redirected off to someone's um someone's own git repository which is a bit cheaty because there isn't the all-important sort of uh integrity checks that um composer would do to make sure that that version is is md5 with the right checksums so i think someone wants to get lots of downloads and lots of stars against their git repository and look like a he-man um yeah so my desire to use taxonomy menu has fallen just a little bit now as a result of the fact that what i've got to do is i've got to modify the container so that it has the um the git command in it so i'm not sure whether it has drush but i didn't need drush in that instance although if i needed drush i might have to use compose well hold on i am i am pulling josh i'm pulling a version of brush with composer so composer is installed but not yet so what i'm doing here is i'm going to go visit the um uh the docker hub uh that i got my drupal uh container from and then i'm gonna drill down to the github repository and see how all the way in which they've built the the container because what i've got to do is i've got to add another layer on top of that container just like a layer cake to add the git command so i'm identifying here what is it what is the container that i'm pulling down so it's i need the drupal 9 with php 74 on an apache platform so i'm going to say my docker container is going to need that as it's prerequisite and i'm going to really do one thing i'm going to grab the apt-get line so if i look in docker hub what i can do is i can be inspired by how they've built their docker by had they built their docker file so if i look at the docker file i can see where they've done their app gets because there's a debian system so there's a few different distributions of linux that you can use inside a docker file microsoft has stolen a few core developers from google to help microsoft build viable windows docker instances with varying degrees of success but you can see here these are the lines that i'm looking for i need to get apt-get install um get so i need to grab that uh that line and um straight off the bat i think i'm making some syntax errors because that final backtick or that backslash needs to be removed from um from get there so i'm replacing a library that's already been installed in the container and i'm replacing it with git so and sometimes there's sort of the last line might say expose port x and it might say run or create a startup file but i'm not interested in any of that all i want to do is create a brand new layer that just contains the get command because that's the reason why my docker compose is failing so i'll save that out and i'll try the docker compose um up command after i double check this i'm not sure why i'm here oh no hold on that's why um so i need to actually change that image because that image reference is now in the docker file so instead of saying please pull this image inside docker compose now i'm saying please build from this docker file and the dockerfile itself has the um the label that um that i'm building from and i still think so what's happening now when i say docker compose build it's attempting to build that new docker file and it's failing because it says failed to build the command bin get returned to non-zero so code 100 in a lot of unix systems or posix systems returning a zero means ah yes success um the the program completed successfully when you receive a non-zero whether it's one negative 127 or in this case returned an error code of hundred um it means that it failed in some way shape or form so what i'm doing is i'm getting rid of all of the backticks and i'm hoping for the best now so you can see the iterative process that i'm going through i make a change i try it again um it attempts to build that docker file and i'm pretty sure that it's going to fail again so if i go back to how that dockerfile was created and i attempt to copy more specifically the lines that they used in github they start off by saying oh yeah i'll update the apt system first and then i'll install git and and that's when sort of magic happened so what have i called by doing this i'm still saying docker compose build so what that means is that i need to look at all of the build lines inside my docker compose file and actually intentionally build those into the images that will eventually be run so it's going through and it's checking for any new libraries any new um software that that container will use as well as grabbing the uh the get and i highlighted a line there which is a sort of a hash code that represents the one new configuration that i place on top of the configuration of drupal 7 4x on apache so i've made one tiny little alteration to what is a fairly large and confusing operating system so as a result the only thing that i really need to send up to the internet is just that layer so if i need to store my version of drupal in a repository somewhere it really won't take up that much space the source of that will remain a part of um a part of github sorry a part of docker hub so it says that the server is up successfully so what i can do is i can uh change the port number from 999 to 9998 i need to change the url because i use 98 in another project so i hope if i excuse me press the enter key uh we're missing the top of the tab there but i'm guessing that it's loading successfully or not so um the iteration continues uh we have a forbidden and i think the forbidden is related to the fact that my drupal instance did not actually go into the public folder so i'll work that theory out by actually going into the running container so what i'm doing is i'm using my command line to go into the computer that's currently executing without its drupal so if i choose the um the runtime name and then say what is it that i want to do in there i can just check via www.html and identify what it is that went wrong so you can see here this is where all my project is so when i instantiated the container there's my drupal my drupal's there it's it seems to be good but when i go to bar dub dub dub html um there was nothing there so what i'm doing is i'm trying to link this guy while the container is running and test it and it still says forbidden and it's partly because of my linking process i've got to link the absolute folder so so when i try to go into html it actually says no i can't go there it's not possible for me to go there and when i go into via dub dub dub it will show that my linking or the way i've linked the two folders together is hasn't worked so i need to be more explicit about describing the the the uh the absolute address to those two folders and when i when i finally set that up right look tada but this is ephemeral one of the change that i've made there is completely temporary when i close docker down or when i when i restart it those settings will just disappear altogether so what i really need to do is i need to double check this linking here where it says opt web to via www.html so i made a booboo in this startup command such that things didn't work out as beautifully as they could so now that i've um now that i've i've confirmed my boo-boo uh i'm actually going to get rid of everything i'm going to delete all of my um volumes i'm going to delete all of my docker images so that i can try this whole process again so um when you create a docker image it sits in memory even when it's not running so what i need to do is i need to actually get rid of any sort of residual image that i might have made before so i'm just going to get rid of the um the the things that we created there should have been three there i don't know why there's only two so now i've got a completely empty um docker environment and i'm just going to do the up again which will go through the entire process of standing up those three um those three microservices and um confirm in my mind that uh drupal indeed on port 8.998 is actually going to work so 999 produces my my database but um 9998 which might take a little while to come up so it does say it's up so if i open a new tab or i add that 8 on to the end it should bring up my all important drupal site so there's my dribble site i seem to be logged into it i don't know how because i don't remember authenticating with it before so there must be a cookie somewhere remembering my instance um so i'm happy with that it seems to seems to work i can look at the um the structure there's a few errors that i need to fix um a few things that i'd have to include in my settings.php and a few permissions that i'd need to reconfigure to make drupal be allowed to write to certain parts of the file system but ostensibly it's standing up when it's supposed to stand up what i want to do now is push those changes that docker compose file and that docker file up back to my repository um note that the env file ain't going with it right so it's it's not um it's not kosher to put up passwords there so what i've done is i've next all authentication from this repository this repository does not contain any username and passwords embedded in any files anywhere that's the work practice that is the goal and i think in the industry you'd be lambasted quite quickly if you start embedding passwords in repositories embedding passwords in files in repositories if you start embedding things deep into the system then then you're going to be sort of vilified for that so think about that um password practice think about where you're putting your private keys and and make sure that it's in a location and in an environment that isn't going to get um isn't going to get looked at a funny thing that i often see is and and i can tell the hackers what to do is to sort of go to the root of people sites and just end with dot env and you might actually see a lot of things that you're not supposed to see because some people might be silly enough to put their env files in the document root of their site which is a very bad thing to do because obviously that env file would contain um stuff that we don't want to show so for the final a few minutes so we're now at quarter 145 so we've got 10 more minutes left and what i thought i would do was confirm that my doctorification of this actually works and i like google cloud the best um i'm gonna sort of put my hand up and say it's the best because of the terminal and there's a lovely chrome plugin to provide you with a combination of vs code on the top and the google cloud shell on the bottom and you're a rockstar you've got all cloud functionalities right there in an environment where you can do dev work and if you don't have a computer that's fast enough or powerful enough to run docker and kubernetes you've got it here um and the other added advantage is you're sitting at the end of some multiple high speed uh interconnects and all of your docker pulls are going to happen you can see here 200 bytes a second 900 megabytes a second oh my god the speed is amazing um but nonetheless there's some weird-ass things that sort of affect us uh one thing that's occurred at least with the um with the google cloud platform is that it's still um stubbornly holding on to um python 2 as its um as its default language um python 2 uh i don't know i'm not a python developer so i don't want to judge um but nonetheless we've got to convert at least this shell into python 3 so that it will work so one thing that um i've realized is is that we have to sort of um yeah not only take the env file with all of its um details all of its passwords but we also have to sort of add some environment variables for the shell that we're in here so that it'll work with python 3 instead of version 2. but yes there's that env file so what i'm doing is manually carrying around the env file and pumping it into my target environments manually but of course with every with every cloud platform there is a secrets manager and maybe you can pull your secrets from the secrets manager uh production environments do not need phpmyadmin so i would suggest that you know that be there just for development purposes only so we would get rid of maybe a couple of these containers that would be developer friendly another point that i haven't made clear is the whole idea of volumes in the docker compose file what we're doing with those volumes is inviting certain parts of our repository directly into our containers many production experts wouldn't use docker compose in fact even the the transition from docker compose to production-ready environments isn't isn't well defined it's better defined in a framework called kubernetes um so there's sort of a fuzzy barrier between moving from docker compose to production environments so much so that um pretty much most ops people will just edit docker files and then move those docker files into a different type of yaml that is more befitting a kubernetes environment that's an area that i haven't gotten into but i'm sure by drupal 10 i'll feel a little bit more confident about maybe showing you a more clear transition into the cloud using um using kubernetes um so i'm still sort of you know trying to come to some conclusion as to why docker compose up is continuing to fail but when i i sort of out tab out to my searches um because it's hit me a few times now in that um the google cloud platform uses python 2 and not python 3. um all of them so aws and azure and google cloud all now have a terminal so for a long time aws didn't and now that they've got sort of a beta program where you can run an interactive terminal now which has the aws command line and gives you a level of permission directly to what you've authenticated to already and it becomes very handy because you can use that as a pre-deployment staging environment to test all of your scripts and confirm all of your processes and make sure that you're you're happy with all of the all of the issues that little dialogue that came up when i said docker build is me authenticating my docker with the cloud platforms docker registry because google cloud and aws all have a registry where you can put your built docker containers into a location before they get put into the cloud before they get put into production so you have this special version control system just for docker containers and nothing else just like docker hub is a um a a repository or or a registry for um for docker containers um but what i have to do is i have to export or i have to set some um some environment variables before i get past these errors and i'm i'm incredulous i'm constantly putting in this you know what's the sign of insanity doing the same thing over and over isn't it so i finally decide that what i'm going to do is i'm going to google openssl 111 is required by libpython3 and really what's happening is that lib ssl 111 is being used by python 2 and and that's why my things aren't aren't happy for me um so where are we we are now at 152 or 55 so we're down to the last two minutes of the of the video so we're getting to the end um it's been a long long walk um this last one is just a a a confirmation that all of my docker compose and all of my docker configurations are going to work in our alternative platform there are other places you can go there's play with docker which is a nice little sort of play pen you can you can walk to somebody else with the docker desktop on their windows machine or or what have you and and try uh the right thing out at the right time but nonetheless um with the last 30 seconds which just shows me exporting the right two variables and then standing up the environment correctly um i bid you a due and hope that you picked the right video to spend one hour and 55 minutes with more likely you've you've clicked at the end and you're more interested in this whole docker thing uh rather than drupal itself but nonetheless um i'm glad you uh you stuck it out and uh i hope to uh to see you guys next time you
Info
Channel: John Perry
Views: 7,498
Rating: 4.8811879 out of 5
Keywords: drupal, drush, composer, docker, web, php, mysql, html, css, apache, debian, gcp, cloud, docker-compose, meetup
Id: XJatVmC5-ro
Channel Id: undefined
Length: 121min 12sec (7272 seconds)
Published: Thu Feb 18 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.