-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PM2 Official Docker Repository #52
Comments
As discussed before with @Unitech, it would be helpful to have it the official |
@vmarchaud I'm sorry but I haven't understood what you have wrote. |
I post here some relevant massages while talking with @Unitech
|
@simonepri Simply put : lets do it What can be done is a docker image that use a bot account to make a PR automatically then we will add it to our CI, what do you think ? |
Yes looks good. This is a draft of the publishing script that works in case we create a fake GitHub account called
#!/bin/bash
hash git 2>/dev/null || { echo >&2 "git not found, exiting."; }
hash hub 2>/dev/null || { echo >&2 "hub not found, exiting."; }
username='keymetrics-bot'
# Generate pm2 file
rm -rf ./docker-pm2/
git clone https://github.com/keymetrics/docker-pm2.git
cd ./docker-pm2/
bash docker-tags.sh > ../pm2
cd ..
rm -rf ./docker-pm2/
echo ""
# Fork their repo
rm -rf ./official-images/
git clone https://github.com/docker-library/official-images.git
cd ./official-images/
hub fork
cd ..
rm -rf ./official-images/
echo ""
# Clone our fork
git clone https://github.com/$username/official-images.git
cd official-images
git remote add upstream https://github.com/docker-library/official-images.git
git fetch upstream
echo ""
# Reset our master in case the fork already exists
git reset --hard upstream/master
git clean -f -d
git push -f
echo ""
# Move the pm2 file
mkdir -p $(dirname ./library/pm2)
mv ../pm2 ./library/pm2
echo ""
# Make the PR
git add .
git commit -m "Update pm2 images"
git push
hub pull-request -m "Update pm2 images" |
This morning I had an idea on how we can actually setup the entire workflow without hosting nothing on our end. Steps:
Everything should work, but I think is bit tricky as system. Also I believe that keeping |
I think the following order will work and seems shorter :
I'm not sure if we need to have the first three step, what do you think ? |
The |
Oh i see, so yeah indeed, your setup is fine. I will create this and give you access. Can you come on http://slack.pm2.io so i can give you the secret of the account i will create ? |
No problem, i will be away the next hour also. Lets discuss on slack when you are available :) |
The
The repo folder structure should be:
Inside the script we have to hardcode the token for GitHub. |
DockerfileFROM alpine:latest
# Updating apk
RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories
RUN apk update
# Install needed tools
RUN apk add git hub bash
# Copy the script
COPY pr.sh .
# Run the script
RUN bash pr.sh pr.sh#!/bin/bash
function ee {
echo -e "\033[31m ✘ \033[0m$1"
exit 1
}
# GitHub auth info
token='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
username='username'
email='[email protected]'
# Repo on which to submit the PR
owner='owner'
repo='repo'
# Checks if the neded tools are installed
hash git 2>/dev/null || { ee "git not found, exiting."; }
hash hub 2>/dev/null || { ee "hub not found, exiting."; }
# Prints git and hub versions
hub version
# Configure hub
hub config --global hub.protocol https
hub config --global user.email $email
hub config --global user.name $username
export GITHUB_TOKEN=$token
echo ""
echo "Logged as $(hub config --get user.name) <$(hub config --get user.email)>"
echo ""
echo "Cloning https://github.com/keymetrics/docker-pm2.git"
# Clones docker-pm2 repo
rm -rf ./docker-pm2/
hub clone keymetrics/docker-pm2
echo ""
echo "Executing docker-tags.sh"
# Generates pm2 file
cd ./docker-pm2/
bash docker-tags.sh > ../pm2 || { ee "unable to execute, exiting."; }
cd ..
# Removes the folder created
rm -rf ./docker-pm2/
echo ""
echo "Cloning https://github.com/$owner/$repo.git"
# Clones their repo
rm -rf ./$repo/
hub clone $owner/$repo || { ee "unable to clone, exiting."; }
cd ./$repo/
echo ""
echo "Forking https://github.com/$owner/$repo.git"
# Makes the fork
hub fork || { ee "unable to fork, exiting."; }
echo ""
echo "Updating remotes"
# Update remotes
hub remote rename origin upstream
hub remote rename $username origin
hub remote set-url upstream https://$token:[email protected]/$owner/$repo.git
hub remote set-url origin https://$token:[email protected]/$username/$repo.git
hub remote -v
hub pull --all
echo ""
echo "Syncing master with $(hub remote get-url upstream)"
# Resets our master to be event with the upstream
hub reset --hard upstream/master
hub clean -f -d
hub push origin -f || { ee "unable to push, exiting."; }
echo ""
echo "Applying changes"
# Moves the pm2 file
mkdir -p $(dirname ./library/pm2)
mv ../pm2 ./library/pm2
echo ""
echo "Pushing changes to $(hub remote get-url origin)"
# Pushes changes to our fork
hub add library/pm2
hub commit -a -m "Update pm2 images"
hub push origin -f || { ee "unable to push, exiting."; }
echo ""
echo "Creating the Pull Request"
# Makes the PR
hub pull-request -m "Update pm2 images" || { ee "unable to create the pr, exiting."; }
cd ..
# Removes the folder created
rm -rf ./$repo/ |
As discussed in #25 it would be interesting to see if we can publish this image as "Official" on the Docker Hub.
The process seems quite simple. We have to simply open a PR here adding a file called
pm2
inside the library folder of the repo.The
pm2
file can be generated automagically using this script i wrote.So why we don't do that?
It seems that the images are rebuilt manually by the docker team. This means that we are not able to setup any sort of automated build like the one we have now.
The text was updated successfully, but these errors were encountered: