Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM golang:1.22 as base

WORKDIR /app

COPY . .

RUN go mod download

RUN go build -o main .

FROM gcr.io/distroless/base

COPY --from=base /app/main .

COPY --from=base /app/static ./static

EXPOSE 8080

CMD [ "./main" ]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This is a simple website written in Golang. It uses the `net/http` package to serve HTTP requests.

## Installing Go on your machine

Download and install Go for your respective OS from `https://go.dev/doc/install`

## Running the server

To run the server, execute the following command:
Expand Down
21 changes: 21 additions & 0 deletions k8s/manifests/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: go-web-app
labels:
app: go-web-app
spec:
replicas: 1
selector:
matchLabels:
app: go-web-app
template:
metadata:
labels:
app: go-web-app
spec:
containers:
- name: go-web-app
image: joethomas97/go-web-app:v1
ports:
- containerPort: 8080
20 changes: 20 additions & 0 deletions k8s/manifests/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Ingress resource for the application
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: go-web-app
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: go-web-app.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: go-web-app
port:
number: 80
14 changes: 14 additions & 0 deletions k8s/manifests/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: go-web-app
labels:
app: go-web-app
spec:
selector:
app: go-web-app
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: ClusterIP