-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add Discord bot and initial commands #190
Open
johnpooch
wants to merge
11
commits into
master
Choose a base branch
from
johnpooch/add-hello-world-discord-bot
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d554cdc
Add Ping/Pong Discord bot
a13cfbb
wip
1eef9bf
Move Dockerfile into subdirectory
8b63c4e
Add Powershell scripts to run Docker correctly
05166fb
Add tests
f2b9093
Add discord functionality
1d7e91a
Make api functions public
7c5a1b9
Add shell scripts for Docker
d99e4f0
Add instructions to README
0335181
Fix build script
1421c69
Add .env explainer
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Description: Build docker image from Dockerfile | ||
|
||
Write-Host "Building Docker image..." | ||
|
||
# Confirm that the script is being executed from the correct directory | ||
if (-not (Test-Path ".docker/docker-run.ps1")) { | ||
Write-Host "You must run this command from the parent directory of this script." | ||
exit | ||
} | ||
|
||
Write-Host "Confirmed that script is being executed from the correct directory." | ||
|
||
$dockerCommand = "docker build --tag 'diplicity' ./.docker" | ||
|
||
Write-Host "Running Docker command: $dockerCommand" | ||
|
||
# Execute the Docker command | ||
Invoke-Expression $dockerCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Description: Build docker image from Dockerfile | ||
|
||
Write-Host "Building Docker image..." | ||
|
||
# Confirm that the script is being executed from the correct directory | ||
if (-not (Test-Path ".docker/docker-run.ps1")) { | ||
Write-Host "You must run this command from the parent directory of this script." | ||
exit | ||
} | ||
|
||
Write-Host "Confirmed that script is being executed from the correct directory." | ||
|
||
$dockerCommand = "docker build --tag 'diplicity' ./.docker" | ||
|
||
Write-Host "Running Docker command: $dockerCommand" | ||
|
||
# Execute the Docker command | ||
Invoke-Expression $dockerCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Description: Create a new docker network called my-net | ||
|
||
Write-Host "Creating Docker network..." | ||
|
||
$dockerCommand = "docker network create -d bridge my-net" | ||
|
||
Write-Host "Running Docker command: $dockerCommand" | ||
|
||
# Execute the Docker command | ||
Invoke-Expression $dockerCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# Description: Create a new docker network called my-net | ||
echo "Creating Docker network..." | ||
|
||
dockerCommand="docker network create -d bridge my-net" | ||
|
||
echo "Running Docker command: $dockerCommand" | ||
|
||
# Execute the Docker command | ||
eval $dockerCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Ensure that this command is being called from the parent directory | ||
# of the Dockerfile. This is necessary for the volume mapping to work | ||
# correctly. | ||
|
||
Write-Host "Running Docker container..." | ||
|
||
# Confirm that the script is being executed from the correct directory | ||
if (-not (Test-Path ".docker/docker-run.ps1")) { | ||
Write-Host "You must run this command from the parent directory of this script." | ||
exit | ||
} | ||
|
||
Write-Host "Confirmed that script is being executed from the correct directory." | ||
|
||
# Base docker run command | ||
$dockerCommand = "docker run" | ||
|
||
# Mount a volume from the host machine to the container. This means | ||
# that the container will have access to the files in the host machine | ||
# and that changes made in the host machine will be reflected in the | ||
# container. | ||
$dockerCommand += " -v .:/go/src/app:ro" # Add volume mapping | ||
|
||
# Specify the network that the container should be connected to. This | ||
# is necessary for the Discord bot to be able to work correctly. | ||
$dockerCommand += " --network my-net" # Specify the network | ||
|
||
# Specify the environment file that should be used by the container. This | ||
# file contains secret environment variables that the application needs | ||
# to run correctly, e.g. DISCORD_BOT_TOKEN. | ||
$dockerCommand += " --env-file ./.env" # Specify the environment file | ||
|
||
# Specify that the 8080 port should be exposed to the host machine. This | ||
# is the port that the API application listens on. | ||
$dockerCommand += " -p 8080:8080" # Map port 8080 | ||
|
||
# Specify that the 8000 port should be exposed to the host machine. This | ||
# is the port that the admin application listens on. | ||
$dockerCommand += " -p 8000:8000" # Map port 8000 | ||
|
||
# Specify the image that should be used to create the container. This | ||
$dockerCommand += " diplicity" | ||
|
||
Write-Host "Running Docker command: $dockerCommand" | ||
|
||
# Execute the Docker command | ||
Invoke-Expression $dockerCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
# Ensure that this command is being called from the parent directory | ||
# of the Dockerfile. This is necessary for the volume mapping to work | ||
# correctly. | ||
|
||
echo "Running Docker container..." | ||
|
||
# Confirm that the script is being executed from the correct directory | ||
if [ ! -f ".docker/docker-run.sh" ]; then | ||
echo "You must run this command from the parent directory of this script." | ||
exit 1 | ||
fi | ||
|
||
echo "Confirmed that script is being executed from the correct directory." | ||
|
||
# Base docker run command | ||
dockerCommand="docker run" | ||
|
||
# Mount a volume from the host machine to the container. This means | ||
# that the container will have access to the files in the host machine | ||
# and that changes made in the host machine will be reflected in the | ||
# container. | ||
dockerCommand+=" -v .:/go/src/app:ro" # Add volume mapping | ||
|
||
# Specify the network that the container should be connected to. This | ||
# is necessary for the Discord bot to be able to work correctly. | ||
dockerCommand+=" --network my-net" # Specify the network | ||
|
||
# Specify the environment file that should be used by the container. This | ||
# file contains secret environment variables that the application needs | ||
# to run correctly, e.g. DISCORD_BOT_TOKEN. | ||
dockerCommand+=" --env-file ./.env" # Specify the environment file | ||
|
||
# Specify that the 8080 port should be exposed to the host machine. This | ||
# is the port that the API application listens on. | ||
dockerCommand+=" -p 8080:8080" # Map port 8080 | ||
|
||
# Specify that the 8000 port should be exposed to the host machine. This | ||
# is the port that the admin application listens on. | ||
dockerCommand+=" -p 8000:8000" # Map port 8000 | ||
|
||
# Specify the image that should be used to create the container. | ||
dockerCommand+=" diplicity" | ||
|
||
echo "Running Docker command: $dockerCommand" | ||
|
||
# Execute the Docker command | ||
eval $dockerCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ game/game.debug | |
|
||
# Diff tool files | ||
*.orig | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zond I'll need to add a
DISCORD_BOT_TOKEN
value to GitHub secrets or something. Can you help me with that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently all the secrets needed are stored in App Engine Datastore, see for example https://github.com/zond/diplicity/blob/master/auth/sendgrid.go#L50 where it fetches a Sendgrid key used to send emails via Sendgrid (which may not be functional anymore, people have reported that email deliveries don't work).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running locally, I typically have just uploaded the secret using e.g. https://github.com/zond/diplicity/blob/master/game/handler.go#L664.