diff --git a/.github/workflows/golang.yml b/.github/workflows/golang.yml new file mode 100644 index 0000000..4e4aafb --- /dev/null +++ b/.github/workflows/golang.yml @@ -0,0 +1,35 @@ +# This is a basic workflow to help you get started with Actions + +name: Golang + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + branches: [ master ] + paths: + - 'golang/**' + - '.github/**' + pull_request: + branches: [ master ] + paths: + - 'golang/**' + - '.github/**' + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Runs a set of commands using the runners shell + - name: Golang build + run: | + cd golang + docker build . diff --git a/README.md b/README.md index d5403cf..c5ccfb2 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ + +

@@ -65,13 +67,13 @@ Jump to [_**example-stacks**_](https://github.com/Stack-Box/StackBox/blob/master ## Support -| Clients/Services | Mysql | Elasticsearch | MongoDB | S3 | -| ---------------- | ----- | ------------ | --------| ---- | -| **Flask** | ✅ | ✅ | ❌ | ✅ | -| **Rails** | ✅ | ❌ | ❌ | ❌ | -| **Vue** | ✅ | ✅ | ❌ | ❌ | -| **Angular** | ✅ | ✅ | ❌ | ❌ | -| **React** | ❌ | ❌ | ❌ | ❌ | +| Clients/Services | Mysql | Elasticsearch | MongoDB | S3 | DynamoDB | +| ---------------- | ----- | ------------ | --------| ---- | ----------| +| **Flask** | ✅ | ✅ | ❌ | ✅ | ✅ | +| **Rails** | ✅ | ❌ | ❌ | ❌ | ❌ | +| **Vue** | ✅ | ✅ | ❌ | ❌ | ❌ | +| **Angular** | ✅ | ✅ | ❌ | ❌ | ❌ | +| **React** | ❌ | ❌ | ❌ | ❌ | ❌ | Other containers that you can bring up: 1. nginx diff --git a/flask/app.py b/flask/app.py index d653392..a6bfd3a 100644 --- a/flask/app.py +++ b/flask/app.py @@ -106,7 +106,7 @@ def s3_view_object(): """ @app.route('/dynamodb_get_items', methods=['GET']) @cross_origin() -def s3_view_object(): +def dynamodb_view_object(): req_body = request.get_json() req_params = request.params.get_json() dynamodb_handler = DynamoDBHandler(req_body["access_key_id"], req_body["access_key"], req_body["region"]) @@ -117,7 +117,7 @@ def s3_view_object(): """ @app.route('/dynamodb_put_item', methods=['POST']) @cross_origin() -def s3_view_object(): +def dynamodb_view_object(): req_body = request.get_json() req_params = request.params.get_json() dynamodb_handler = DynamoDBHandler(req_body["access_key_id"], req_body["access_key"], req_body["region"]) diff --git a/golang/Dockerfile b/golang/Dockerfile new file mode 100644 index 0000000..c3fbd68 --- /dev/null +++ b/golang/Dockerfile @@ -0,0 +1,31 @@ +# We specify the base image we need for our +# go application +FROM golang:1.12.0-alpine3.9 + +# We create an /app directory within our +# image that will hold our application source +# files +RUN mkdir /app + +# We copy everything in the root directory +# into our /app directory +ADD . /app + +# We specify that we now wish to execute +# any further commands inside our /app +# directory +WORKDIR /app + +# Add this go mod download command to pull in any dependencies +RUN go mod download + +# we run go build to compile the binary +# executable of our Go program +RUN go build -o main . + +# Expose port 8080 to the outside world +EXPOSE 8080 + +# Our start command which kicks off +# our newly created binary executable +CMD ["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/app/main"] diff --git a/golang/main.go b/golang/main.go new file mode 100644 index 0000000..70474b7 --- /dev/null +++ b/golang/main.go @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + "html" + "log" + "net/http" +) + +func main() { + + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) + }) + + http.HandleFunc("/hi", func(w http.ResponseWriter, r *http.Request){ + fmt.Fprintf(w, "Hi") + }) + + log.Fatal(http.ListenAndServe(":8080", nil)) + +} \ No newline at end of file diff --git a/master.yaml b/master.yaml index 46ab560..2be1efe 100644 --- a/master.yaml +++ b/master.yaml @@ -92,3 +92,8 @@ rubyonrails: volumes: - "./rubyonrails:/app" - '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/app/node_modules' + +golang: + build: ./golang + ports: + - "3001:8080" diff --git a/stack.py b/stack.py index 685162f..5eb81e2 100755 --- a/stack.py +++ b/stack.py @@ -7,7 +7,7 @@ ip = ni.ifaddresses('en0')[ni.AF_INET][0]['addr'] # List of clients -CLIENTS = ['flask', 'vue', 'rubyonrails', 'angular', 'react'] +CLIENTS = ['flask', 'vue', 'rubyonrails', 'angular', 'react', 'golang'] # docker-compose.yml skeleton to fill out using "service" entries above. COMPOSITION = {'version': '3', 'services': {}} diff --git a/stackbox.sh b/stackbox.sh index e5cd963..c28aade 100755 --- a/stackbox.sh +++ b/stackbox.sh @@ -42,7 +42,7 @@ PS3='Select your backend: ' echo "BACKEND OPTIONS:" -backend_options=("Flask" "Rails") +backend_options=("Flask" "Rails" "Golang") select opt in "${backend_options[@]}" do case $opt in @@ -56,6 +56,11 @@ do stack+=("rubyonrails") break; ;; + "Golang") + echo "You've chosen Golang" + stack+=("golang") + break; + ;; *) echo "Invalid option $REPLY";; esac done