This commit is contained in:
Lucas Gravley 2020-03-09 13:33:18 -05:00
Родитель 692798bc33
Коммит beb105fd83
5 изменённых файлов: 162 добавлений и 0 удалений

21
.github/mona-recipe.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,21 @@
---
##########################################
##########################################
## Mona recipe file for building probot ##
##########################################
##########################################
# Legend:
# This file is used by GitHub Services hubot 'mona'
# To build and deploy the Probot app for testing, demo,
# and general automation
##############
# Build Vars #
##############
docker_tag: probot-rally
###############
# Deploy Vars #
###############
deploy_port: 3001

50
Dockerfile Normal file
Просмотреть файл

@ -0,0 +1,50 @@
#################################
## Dockerfile for Probot-Rally ##
#################################
## Base image
FROM node:10-alpine
## Set the Labels
LABEL version="1.0" \
description="Probot app to verify Rally issues in a Pull Request" \
maintainer="GitHub Professional Services <services@github.com>"
## These files are copied separately to allow updates
## to the image to be as small as possible
COPY --chown=node:node package.json /opt/probot-rally/
COPY --chown=node:node index.js /opt/probot-rally/
COPY --chown=node:node lib /opt/probot-rally/lib
## You should edit .env.example and save it before building this image
## Future updates to this Dockerfile _may_ move this over to
## pure environment variables in Docker, so it can be passed at the CLI.
## This will be purely based on demand
COPY --chown=node:node .env /opt/probot-rally/
## This can probably be removed, but users will have to make sure they
## run the container, then copy the key. This helps avoid that for folks
## using this in their enterprise environments
COPY --chown=node:node .ssh/probot-rally.pem /opt/probot-rally/.ssh/
## We need Python for Probot
RUN apk add --no-cache make python
## Best practice, don't run as `root`
USER node
## Set our working directory
WORKDIR /opt/probot-rally
## Not strictly necessary, but set permissions to 400
RUN chmod 400 /opt/probot-rally/.ssh/probot-rally.pem /opt/probot-rally/.env
## Install the app and dependencies
RUN npm install
## This app will listen on port 3000
EXPOSE 3000
## This does not start properly when using the ['npm','start'] format
## so stick with just calling it outright
CMD npm start

26
docker-compose.yml Normal file
Просмотреть файл

@ -0,0 +1,26 @@
---
###################################
# Docker compose for Probot-Rally #
###################################
###########
# Version #
###########
version: '3.3'
####################
# Set the services #
####################
services:
probot-rally:
# Set the open ports
ports:
- '3000:3000'
# Set to restart on error
restart: always
# Set logging informatgion
logging:
options:
max-size: 1g
# Start the image
image: probot-rally

62
docs/DockerDeploy.md Normal file
Просмотреть файл

@ -0,0 +1,62 @@
# Docker Deployment Guide
This document will help outline the steps needed to deploy the **Probot Rally** **GitHub App** as a **Docker** container in your environment. This method should allow for multiple automations and ease of use.
## How to Deploy
### Create GitHub App on GitHub
You can find all the steps to create the GitHub app from the [README](https://github.com/github/probot-rally/blob/master/.github/README.md) on the root of the source code. You will need the **endpoints**, and `.pem` created to be able to deploy the **GitHub App**.
### Prepare the source code
You will first need to clone the source code to your local environment that will run the **Docker** container.
- Clone the codebase
- `git clone https://github.com/github/probot-rally.git`
- Change directory to inside the code base
- `cd probot-rally/`
- Create `.env` from `.env.example`
- `cp .env.example .env`
- Update the `.env` with thew needed fields, such as:
- `GHE_HOST` - This is a required field for **GitHub Enterprise Server** implementations (_Example: github.mycompany.com_)
- `APP_ID` - The App ID of the **GitHub App**
- `RALLY_USERNAME` - The username to connect to **Rally**
- `RALLY_PASSWORD` - The password to connect to **Rally**
- `RALLY_HOSTNAME` - This is the hostname of your **Rally** instance (can be configured in the YAML)
- `RALLY_STRICT_SSL` - Set this to false for testing in a development environment (can be configured in the YAML)
- `RALLY_PORT` - If not using the standard HTTP/HTTPS ports (can be configured in the YAML)
- `RALLY_PROTOCOL` - Whether to use `http` or `https`... useful for testing in Dev (can be configured in the YAML)
You will need to copy the contents of the `.pem` created from **GitHub** to the location: `/opt/probot-rally/.ssh/probot-rally.pem`. This will be used when the container is built and deployed.
Once you have the `.env` file configured, you are ready to start the building of the container.
### Build the Docker container
Once you have configured the **GitHub App** and updated the source code, you should be ready to build the container.
- Change directory to inside the code base
- `cd probot-rally/`
- Build the container
- `sudo docker build -t probot-rally .`
- This process should complete successfully and you will then have a **Docker** container ready for deployment
### Run the Docker container
Once the container has been successfully built, you can deploy it and start utilizing the **GitHub App**.
#### Start the container with docker-compose
If you have docker-compose installed, you can simply start and stop the **Docker** container with:
- `cd probot-rally/; docker-compose up -d`
This will start the container in the background and detached.
#### Start Docker container Detached in background
- Start the container detached with port assigned (*Assuming port 3000 for the webhook*)
- `sudo docker run -d -p 3000:3000 probot-rally`
- You should now have the container running in the background and can validate it running with the command:
- `sudo docker ps`
- This should show the `probot-rally` alive and running
#### Start Docker container attached in forground (Debug)
- If you need to run the container in interactive mode to validate connectivity and functionality:
- `sudo docker run -it -p 3000:3000 probot-rally`
- You will now have the log of the container showing to your terminal, and can validate connectivity and functionality.
#### Connect to running Docker container (Debug)
- If you need to connect to the container thats already running, you can run the following command:
- `sudo docker exec -it probot-rally /bin/sh`
- You will now be inside the running **Docker** container and can perform any troubleshooting needed

3
lib/README.md Normal file
Просмотреть файл

@ -0,0 +1,3 @@
# Probot Rally Library
This folder holds the library files needed to help build and run the **GitHub** **Rally** Probot.