search close

Example Helloworld Test Web Application

access_time Updated Mar 27, 2023

Hello world Test Web Application

This uses the helloworld example included with the Signal Sciences Golang module as a test web application named helloworld.

See: main.go in the sigsci-module-golang helloworld example

Dockerfile

Dockerfile to build the signalsciences/example-helloworld container:

docker build . -t signalsciences/example-helloworld:latest
FROM golang:1.13

# Image metadata
LABEL com.signalsciences.sigsci-module-golang.examples="helloworld"
LABEL maintainer="Signal Sciences <support@signalsciences.com>"

# Install sigsci golang module (with examples)
RUN go get github.com/signalsciences/sigsci-module-golang

# Use the helloworld example as the test app
WORKDIR /go/src/github.com/signalsciences/sigsci-module-golang/examples

ENTRYPOINT [ "go", "run", "./helloworld" ]

Kubernetes Deployment File

Kubernetes example-helloworld deployment file (without the Signal Sciences Agent):

kubectl apply -f example-helloworld.yaml
apiVersion: v1
kind: Service
metadata:
  name: helloworld
  labels:
    app: helloworld
spec:
  ports:
  - name: http
    port: 8000
    targetPort: 8000
  selector:
    app: helloworld
  type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: helloworld
  labels:
    app: helloworld
spec:
  replicas: 2
  selector:
    matchLabels:
      app: helloworld
  template:
    metadata:
      labels:
        app: helloworld
    spec:
      containers:
      - name: helloworld
        image: signalsciences/example-helloworld:latest
        imagePullPolicy: IfNotPresent
        args:
        # Address for the app to listen on
        - localhost:8000
        ports:
        - containerPort: 8000