Skip to content

Commit

Permalink
Merge pull request #38 from guidemetothemoon/master
Browse files Browse the repository at this point in the history
Added support for Harry Potter category, Sprint Name Generator Docker image, div improvements
  • Loading branch information
flostadler authored Jul 12, 2022
2 parents a40f914 + 590b9b2 commit 60c28b7
Show file tree
Hide file tree
Showing 14 changed files with 4,120 additions and 2,561 deletions.
44 changes: 33 additions & 11 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
IMAGE_NAME: ${{ secrets.DOCKER_HUB_USERNAME }}

steps:

- name: Set up Go 1.13
- name: Set up Go 1.18
uses: actions/setup-go@v1
with:
go-version: 1.13
go-version: 1.18
id: go

- name: Check out code into the Go module directory
Expand All @@ -28,35 +31,54 @@ jobs:
fi
- name: Build api
run: go build -v -o name-gen github.com/flostadler/name-generator/cmd/name-generator
run: go build -v -o main ${{ github.workspace }}/cmd/name-generator

- name: Build wasm
run: GOOS=js GOARCH=wasm go build -o web/generator.wasm github.com/flostadler/name-generator/cmd/web
run: GOOS=js GOARCH=wasm go build -o web/generator.wasm ${{ github.workspace }}/cmd/web

- name: Copy wasm_exec
run: cp $GOROOT/misc/wasm/wasm_exec.js web/wasm_exec.js
run: cp $GOROOT/misc/wasm/wasm_exec.js ${{ github.workspace }}/web/wasm_exec.js

- name: Use Node.js 12.x
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 14.x

- run: npm install
working-directory: ./web
working-directory: ${{ github.workspace }}/web

- run: npm run build --if-present
working-directory: ./web
working-directory: ${{ github.workspace }}/web
env:
CI: true

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build Docker image
run: docker build . -f ${{ github.workspace }}/build/package/Dockerfile -t ${{ env.IMAGE_NAME }}/sprint-name-generator:${{github.run_number}}

- name: Run container image security scan
uses: Azure/container-scan@v0
with:
image-name: ${{ env.IMAGE_NAME }}/sprint-name-generator:${{github.run_number}}
severity-threshold: CRITICAL
run-quality-checks: true

- name: Push Docker image
run: docker push ${{ env.IMAGE_NAME }}/sprint-name-generator:${{github.run_number}}

- name: Install SSH Client
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DEPLOY_KEY }}

- name: Deploy Page
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
SSH: true
BRANCH: gh-pages
FOLDER: web/build
FOLDER: ${{ github.workspace }}/web/build
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Florian Stadler

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Sprint-Name-Generator
[Sprint Name Generator](https://sprintnamegenerator.com)

Built by:
- [Florian Stadler](https://github.com/flostadler) - Go -> Wasm
- [Wolfgang Ederer](https://github.com/wederer) - Frontend

## Usage

### Build the image locally

You will need to run a few commands to get necessary files generated.

1. Set environment variables:

* `GOROOT=[path to Go installation folder]`
* `GOOS=js`
* `GOARCH=wasm`

2. Run below commands:

``` bash
go build -o web/generator.wasm cmd/web
cp $GOROOT/misc/wasm/wasm_exec.js web/wasm_exec.js
cd web
npm install
npm run build --if-present

docker build -t sprint-name-generator -f build/package/Dockerfile .
```

3. Start the container:

`docker run -dp 3000:80 sprint-name-generator:latest`

### Run latest image from Docker Hub
``` bash
docker pull guidemetothemoon/sprint-name-generator:[image_tag]
docker run -dp 3006:80 guidemetothemoon/sprint-name-generator:[image_tag]
```

## Images

Original prebuilt image available at [Dockerhub](https://hub.docker.com/r/flostadler/name-generator)

Updated, newest image available at [guidemetothemoon/sprint-name-generator](https://hub.docker.com/r/guidemetothemoon/sprint-name-generator)
17 changes: 3 additions & 14 deletions build/package/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
FROM golang:alpine as builder
RUN mkdir /build
ADD . /build/
COPY go.mod /go/src/github.com/flostadler/name-generator/cmd/name-generator/go.mod
COPY go.sum /go/src/github.com/flostadler/name-generator/cmd/name-generator/go.sum
RUN apk add git
WORKDIR /build
RUN go mod download
RUN go build -o main github.com/flostadler/name-generator/cmd/name-generator
FROM alpine
EXPOSE 80
COPY --from=builder /build/main /app/
WORKDIR /app
CMD ["./main"]
FROM nginx:latest
COPY web/build /usr/share/nginx/html/
EXPOSE 80
6 changes: 5 additions & 1 deletion cmd/web/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build js,wasm
// go:build js,wasm

package main

Expand All @@ -8,6 +8,7 @@ import (
"github.com/flostadler/name-generator/pkg/generators/docker"
"github.com/flostadler/name-generator/pkg/generators/got"
"github.com/flostadler/name-generator/pkg/generators/marvel"
"github.com/flostadler/name-generator/pkg/generators/hp"
"syscall/js"
)

Expand All @@ -30,6 +31,9 @@ func main() {
gen.Set("got", js.FuncOf(func (this js.Value, inputs []js.Value) interface{} {
return got.Generate()
}))
gen.Set("hp", js.FuncOf(func (this js.Value, inputs []js.Value) interface{} {
return hp.Generate()
}))

js.Global().Set("NameGenerator", gen)
<-c
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/flostadler/name-generator

go 1.13
go 1.18

require (
github.com/docker/docker v1.13.1
github.com/gorilla/mux v1.7.1
github.com/docker/docker v20.10.17+incompatible
github.com/gorilla/mux v1.8.0
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo=
github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/gorilla/mux v1.7.1 h1:Dw4jY2nghMMRsh1ol8dv1axHkDwMQK2DHerMNJsIpJU=
github.com/gorilla/mux v1.7.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/docker/docker v20.10.17+incompatible h1:JYCuMrWaVNophQTOrMMoSwudOVEfcegoZZrleKc1xwE=
github.com/docker/docker v20.10.17+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
Loading

0 comments on commit 60c28b7

Please sign in to comment.