Skip to content
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

Get production server to automatically deploy new version when master changes #48

Closed
amcewen opened this issue Nov 2, 2021 · 2 comments
Labels
deployment Issues about the production server

Comments

@amcewen
Copy link
Member

amcewen commented Nov 2, 2021

The production server is running off the master branch, but currently to update it you need to log in and then run these steps:

  1. cd optimism
  2. git pull
  3. docker-compose build
  4. docker-compose up

We should have it auto-deploy when there are new commits to master.

@amcewen amcewen added the deployment Issues about the production server label Nov 2, 2021
@amcewen
Copy link
Member Author

amcewen commented Dec 7, 2021

Set up a new Github Action to deploy this whenever something is pushed to master.

There's probably a better way to do it (running docker-compose build in the action and then pushing the containers over to the site, for example), but given there are just the four steps listed in the description at present I've gone with a short ssh script.

Needed to set up new Action Secrets in the Secrets section of Settings for the repo, to hold REMOTE_HOST_PROD, REMOTE_USER_PROD and SSH_PRIVATE_KEY_PROD

SSH_PRIVATE_KEY_PROD contains an ssh key that I created just for this:

  1. ssh-keygen -f /path/to/somewhere/suitable/id_rsa with no passphrase
  2. ssh-copy-id -i /path/to/somewhere/suitable/id_rsa.pub PRODUCTION_USER@PRODUCTION_HOST to allow the key access to the server
  3. Copy the contents of /path/to/somewhere/suitable/id_rsa into SSH_PRIVATE_KEY_PROD

You can run the action manually by going to https://github.com/DoESLiverpool/optimism/actions/workflows/deploy-to-production.yaml but it should automatically deploy when something is pushed to master. It seemed to work fine when I just tried it manually, so now to test with a new push to master...

@amcewen
Copy link
Member Author

amcewen commented Dec 7, 2021

docker-compose restart just restarts the existing containers, and doesn't pick up any new ones, so I had to switch that to docker-compose down followed by docker-compose up -d.

But now the site auto deploys when anyone pushes new changes to master!!! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployment Issues about the production server
Projects
None yet
Development

No branches or pull requests

1 participant