Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Latest commit

 

History

History
85 lines (75 loc) · 3.77 KB

README-cloud.md

File metadata and controls

85 lines (75 loc) · 3.77 KB

Running on Google Cloud VM Instance

  • First you need to set up your Google Cloud Instance
  • When you set up a cloud account you will get $300 credit!
  • You will need to go to Google Cloud Platform
  • Then to console where you can set up your compute engine
  • Watch this video for help with inital setup video
  • You should only need machine-type f1-micro (1 vCPU, 0.6 GB memory)
    • This will help make your $300 credit last longer

ssh into your vm instance

  • I prefer to do this on my local machine but you can also do it in browser within a shell
  • Install gcloud sdk on your local machine.. steps are here
  • There will be a generated ssh that you can copy and paste into your terminal to ssh into your vm instance using gcloud Alt text
  • Once you're inside your instance within your terminal it should look something like this Alt text

Download Redis

  • Awesome instructions here
  • Very easy and can be completed in < 10 minutes
  • Be sure to create a secure password if you choose to configure remote access (recommended >= 32 characters)
  • Find your external IP on your VM console (needed for the HOST env variable)

Download Docker

  • Awesome instructions here
  • My tl;dr instructions are below
  • Note that you will likely need to add sudo infront of each command
    • Quickest way to fix this when you get the permission denied error
    • $ sudo !!
    • This is a shortcut to run previous command but with super user permissions
# SCRIPT FOR CPUs ONLY
apt-get -y update

# If you have issues with this command, omit python-software-properties
apt-get -y --no-install-recommends install \
  curl \
  apt-utils \
  python-software-properties \
  software-properties-common

add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

# If you need to add sudo as prefix to these commands be sure to add sudo in front of the "apt-key add -"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -

apt-get update
apt-get install -y docker-ce

Check that install worked

  • $ docker --version
  • If this shows your docker version then you've successfully installed docker on your vm instance

Clone your git repository to run within docker

Build the docker image

  • cd into twitter-bot directory
  • $ sudo docker build -t bot .

Check if image was created

$ sudo docker image ls

Run docker image in a container

$ sudo docker run -d \
  --name bot_name \
  --restart unless-stopped \
  -e CONSUMER_KEY="some consumer ID" \
  -e CONSUMER_SECRET="some consumer secret KEY" \
  -e KEY="some key ID" \
  -e SECRET="some secret key ID" \
  -e HOST="external ip address" \
  -e REDIS_PASS="some password" \
  -v $PWD:/work \
  bot

Check that the container is running

  • $ sudo docker container ls
  • $ sudo docker logs bot_name

Google Cloud Terminal Commands

Alt text Alt text