Skip to content

Commit

Permalink
added support for docker containerizing
Browse files Browse the repository at this point in the history
  • Loading branch information
EthyMoney committed Jan 9, 2024
1 parent f1f6192 commit 75553db
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 9 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
.vscode
*.log
.npmrc
.jshintrc
.eslintrc
.gitignore
.gitattributes
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Base image for nodejs (LTS)
FROM node:lts

# Set the shell to bash
SHELL ["/bin/bash", "-c"]

# Create app directory
WORKDIR /usr/src/app

# Copy in the src files
COPY . .

# Replace the config file with the docker template file (prevents leaking your keys to the docker image, you're welcome)
RUN mv config/config-docker-template.json config/config.json

# Install the production dependencies
RUN npm ci --only=production

# Expose port 3000 for API
EXPOSE 3000

# Set the node environment to production
ENV NODE_ENV production

# Define the app run command
CMD [ "npm", "start" ]
8 changes: 7 additions & 1 deletion backend/trello.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
// This is where the backend logic to handle creating a new trello card will go.
// We will use the Trello API to create a new card based on the info submitted in the form.

const config = require("./config.json");
const config = require("../config/config.json");
const fetch = require('node-fetch');
const FormData = require('form-data');
const trelloBoards = config.trelloBoards;
const trelloLabels = config.trelloBoardLabels;

// Check to see if the config file is valid (this will catch a docker user that forgot to fill this in)
if (!config.trelloAppKey || !config.trelloUserToken || !config.trelloBoards || !config.trelloBoardLabels) {
console.error("Invalid config file! Please make sure you have specified your Trello app key, user token, and at least one board and label in the config file.\n" +
"If this is your first time running this app, please see the README for instructions on how to get your Trello app key and user token. These need to go in the config/config.json file.\n");
process.exit(1);
}

// Some terms to understand:
// trelloId: This is the ID of the board or element instance as you see it in your browser URL bar when viewing the board. This is NOT the same as the board ID!
Expand Down
140 changes: 140 additions & 0 deletions config/config-docker-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"trelloBoards": [
{
"frontendEventSelection": "Build Season",
"trelloId": ""
},
{
"frontendEventSelection": "Duluth - Northern Lights",
"trelloId": ""
},
{
"frontendEventSelection": "Duluth - Lake Superior",
"trelloId": ""
},
{
"frontendEventSelection": "10,000 Lakes",
"trelloId": ""
},
{
"frontendEventSelection": "Granite City",
"trelloId": ""
},
{
"frontendEventSelection": "Great Northern",
"trelloId": ""
}
],
"trelloBoardLabels": [
{
"name": "CANBus fault",
"color": "lime"
},
{
"name": "Code - C++",
"color": "blue"
},
{
"name": "Code - General",
"color": "blue"
},
{
"name": "Code - Java",
"color": "blue"
},
{
"name": "Code - LabView",
"color": "blue"
},
{
"name": "Code - Python",
"color": "blue"
},
{
"name": "Communication - Limelight",
"color": "purple"
},
{
"name": "Configuration",
"color": "sky"
},
{
"name": "Driver Station",
"color": "pink"
},
{
"name": "Electronic - Brownout",
"color": "red"
},
{
"name": "Electronic - Communication",
"color": "red"
},
{
"name": "Electronic - General",
"color": "red"
},
{
"name": "Electronic - Pneumatics",
"color": "red"
},
{
"name": "Electronic - Wiring",
"color": "red"
},
{
"name": "Electronic - incompatible components",
"color": "red"
},
{
"name": "Field - Brownouts",
"color": "black"
},
{
"name": "Field - Communication",
"color": "black"
},
{
"name": "Field - General",
"color": "black"
},
{
"name": "Field - roboRIO reboot",
"color": "black"
},
{
"name": "Firmware update",
"color": "orange"
},
{
"name": "Practice Field",
"color": "green"
},
{
"name": "Raspberry Pi",
"color": "yellow"
},
{
"name": "Other or not sure",
"color": "black"
},
{
"name": "Critical Priority",
"color": "red"
},
{
"name": "High Priority",
"color": "orange"
},
{
"name": "Medium Priority",
"color": "yellow"
},
{
"name": "Low Priority",
"color": "green"
}
],
"trelloAppKey": "",
"trelloUserToken": ""
}
12 changes: 6 additions & 6 deletions backend/config.json → config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
"trelloBoards": [
{
"frontendEventSelection": "Build Season",
"trelloId": "idy3xZJW"
"trelloId": ""
},
{
"frontendEventSelection": "Duluth - Northern Lights",
"trelloId": "pm29P25h"
"trelloId": ""
},
{
"frontendEventSelection": "Duluth - Lake Superior",
"trelloId": "5jzi7iPY"
"trelloId": ""
},
{
"frontendEventSelection": "10,000 Lakes",
"trelloId": "ijkLQFUb"
"trelloId": ""
},
{
"frontendEventSelection": "Granite City",
"trelloId": "y35B6h3q"
"trelloId": ""
},
{
"frontendEventSelection": "Great Northern",
"trelloId": "w7CtTrwK"
"trelloId": ""
}
],
"trelloBoardLabels": [
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node backend/host.js"
"start": "node backend/host.js",
"docker-build": "docker build -t ultimate360/mn-csa-website .",
"docker-run": "docker run -d --name mn-csa-website -p 3000:3000 -v mn-csa-website:/usr/src/app/config:rw ultimate360/mn-csa-website",
"docker-push": "docker push ultimate360/mn-csa-website"
},
"author": "Logan S. - EthyMoney",
"license": "MIT",
Expand All @@ -16,4 +19,4 @@
"form-data": "^4.0.0",
"node-fetch": "^2.7.0"
}
}
}

0 comments on commit 75553db

Please sign in to comment.