-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from kenriortega/development
Development
- Loading branch information
Showing
8 changed files
with
207 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Dockerfile References: https://docs.docker.com/engine/reference/builder/ | ||
|
||
# Start from the latest golang base image | ||
FROM golang:1.16-alpine as builder | ||
|
||
# Add Maintainer Info | ||
LABEL maintainer="Kenrique Ortega <[email protected]>" | ||
|
||
# Set the Current Working Directory inside the container | ||
WORKDIR /app | ||
|
||
# Copy go mod and sum files | ||
COPY go.mod go.sum ./ | ||
|
||
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed | ||
RUN go mod download | ||
|
||
# Copy the source from the current directory to the Working Directory inside the container | ||
COPY . . | ||
|
||
# Build the Go app | ||
RUN go build -ldflags "-s -w" -o /app/ngonx cmd/main.go | ||
|
||
######## Start a new stage from scratch ####### | ||
FROM alpine:latest | ||
|
||
RUN apk --no-cache add ca-certificates | ||
|
||
# Build Args | ||
ARG APP_DIR=/app | ||
|
||
# Create APP Directory | ||
RUN mkdir -p ${APP_DIR} | ||
|
||
WORKDIR /app/ | ||
|
||
# Copy the Pre-built binary file from the previous stage | ||
COPY --from=builder /app/ngonx . | ||
COPY --from=builder /app/ngonx.yaml . | ||
|
||
# Expose port 8080 to the outside world | ||
EXPOSE 8080 | ||
|
||
# Declare volumes to mount | ||
VOLUME [${APP_DIR}] | ||
|
||
# Command to run the executable | ||
CMD ["./ngonx"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment # Type of Kubernetes resource | ||
metadata: | ||
name: ngonx-proxy # Name of the Kubernetes resource | ||
spec: | ||
replicas: 3 # Number of pods to run at any given time | ||
selector: | ||
matchLabels: | ||
app: ngonx-proxy # This deployment applies to any Pods matching the specified label | ||
template: # This deployment will create a set of pods using the configurations in this template | ||
metadata: | ||
labels: # The labels that will be applied to all of the pods in this deployment | ||
app: ngonx-proxy | ||
spec: # Spec for the container which will run in the Pod | ||
containers: | ||
- name: ngonx-proxy | ||
image: kenriortega/ngonx-proxy:0.1.0 | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 8080 # Should match the port number that the Go application listens on | ||
livenessProbe: # To check the health of the Pod | ||
httpGet: | ||
path: /health | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 5 | ||
periodSeconds: 15 | ||
timeoutSeconds: 5 | ||
readinessProbe: # To check if the Pod is ready or not | ||
httpGet: | ||
path: /readiness | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 5 | ||
timeoutSeconds: 1 | ||
--- | ||
apiVersion: v1 | ||
kind: Service # Type of kubernetes resource | ||
metadata: | ||
name: ngonx-proxy-service # Name of the resource | ||
spec: | ||
type: NodePort # If you're deploying on cloud, you can use `type: LoadBalancer`. It will automatically provision a load balancer with the cloud provider that will route traffic to your application. | ||
ports: # Take incoming HTTP requests on port 9090 and forward them to the targetPort of 8080 | ||
- name: http | ||
port: 9090 | ||
targetPort: 8080 | ||
selector: | ||
app: ngonx-proxy # Map any pod with name ngonx-proxy to this service |