3/15/2023 0 Comments Simple git server dockerIn order to get the script called, I add an additional line the the post-receive hook which was added above. I add a bin directory to my project and include in that directory a deploy.sh script which carries out any actions required, and also copies the plugin files to the final destination on the server. So the next part of the process I add is to include a processing script in the project which is used to complete any processing that the particular plugin I’m working on needs. This pushes the latest changes to the remote repository, where the post-receive hook runs and checks the code out into the deployed directory for the project. In order to deploy the code, once I’ve made sure everything is correct and I want to push it out the the server I just run: git push live master On my mac I use a vagrant ubuntu virtual machine for development, so I would move to the plugin development directory and add a remote with: git remote add live adds a new remote destination for the project. The other piece of the puzzle is to add this bare repository as a remote destination on the machine where you do your development. Of course we could check the files out into the final destination directory where we want the plugin to live on the live server, but the advantage of checking them into a temporary store is that we can run any other process which needs to happen before they are moved into place. It’s not a repository, just a copy of the files. The interesting point is that when the files are checked out, there is no. Essentially, what it means is when the repository receives a push command, the files are checked out into the deployed directory. That may appear wrapped on your screen, but it’s all one line. Git -work-tree=/usr/local/sites/deployed/myplugin -git-dir=/usr/local/sites/deploy/myplugin.git checkout -f In this script we add the following #!/bin/sh You do this with your favourite editor by adding a script called post-receive in the. The next step is to add a hook into this new repository which will be run when a git push is received. In the repository directory you need to initiate a ‘bare’ repository which is a repository which contains all the branch and history information, but doesn’t contain any of the actual code. I also set the permissions to be owned by my user and the group set to www-data although all you need to do is make sure that the user you use has ssh access to the server. The directories can be called anything you want, I use deploy.git for the repository and deployed for the checked out code. On my server I’ve used /usr/local/sites as the home for all my sites so that was an obvious choice for these directories as well. You also need to set up a directory where the checked out code is going to live. The first part of the process is to set up a new ‘bare’ repository for your code base on your live server. If you don’t use it, or don’t use revision control at all then you can probably stop reading here! So the process I’m going to describe here is a slightly more complex process, but it makes it easy and quick to deploy your code changes with a simple git push.Īn obvious assumptions here is that you use git for revision control. The ideal deploy process would be a simple, single command which can be run to do a complete deploy. You don’t really want to be running git pull and then some other processes to produce the final version of the code on the live server every time you make a change. It will also mean that those directories will need to be masked from the web server or they become a target for hackers.Īnother downside of using a simple pull command is that there may be some processes which need to be run when the code is deployed, like for example some css pre-processing. git directory and a full history of all the branches and changes made. The trouble is that this will mean the live version of the code will include the. Obviously, the simplest way to deploy with git is to make the live plugin a repository and just run git pull in the directory and update the code. # copy package.This post is going to describe how I use git for code deploy and updates to plugin code to my live WordPress sites. My frontend/Dockerfile: FROM node:10.18.0-alpine AS build git/ folder into my container because it is outside the Dockerfile's context. I also want to use git inside my container too. I am using the Remote-Containers extension on VSCode to work directly inside my containers, so that I won't have to rebuild my containers for every change. The project folder hierarchy looks like this: I am using Docker-compose to split my webapp into two containers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |