From bc9c5b6df250a6cd3f07fe214414416907820672 Mon Sep 17 00:00:00 2001 From: Isaac Johnson Date: Wed, 21 Feb 2024 18:39:51 -0600 Subject: [PATCH] Dockerfile, kubernetes manifest and README update --- Dockerfile | 30 +++++++++++++++++++++ README.md | 10 +++++++ kubernetes/deploy.yaml | 59 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 Dockerfile create mode 100644 kubernetes/deploy.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..289371f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# Use an official Node runtime as a parent image +FROM node:14-alpine + +# Set the working directory in the container to /app +WORKDIR /app + +# Copy package.json and package-lock.json to the working directory +COPY package*.json ./ + +# Install the application dependencies +RUN npm install + +# Copy the rest of the application to the working directory +COPY . . + +# Build the application +RUN npm run build + +# Use an official Nginx runtime as a parent image for the runtime stage +FROM nginx:stable-alpine + +# Copy the build output to replace the default Nginx contents. +COPY --from=0 /app/build /usr/share/nginx/html + +# Expose port 80 on the container +EXPOSE 80 + +# Start Nginx +CMD ["nginx", "-g", "daemon off;"] + diff --git a/README.md b/README.md index 50c84c6..5c5a44b 100644 --- a/README.md +++ b/README.md @@ -118,3 +118,13 @@ This section has moved here: [https://facebook.github.io/create-react-app/docs/d ### `npm run build` fails to minify This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) + +### Dockerfile + +One can build the containerized version using `docker build -t pomodoro .` + +One can then run it using `docker run -d -p 8080:80 pomodoro` + +There is also a Kubernetes manifest yaml. Update the ingress as you see fit, but it will need a valid ClusterIssuer and DNS name if using Nginx. + + diff --git a/kubernetes/deploy.yaml b/kubernetes/deploy.yaml new file mode 100644 index 0000000..36977f7 --- /dev/null +++ b/kubernetes/deploy.yaml @@ -0,0 +1,59 @@ +apiVersion: v1 +kind: Service +metadata: + name: pomosimple +spec: + selector: + app: pomosimple + ports: + - protocol: TCP + port: 80 + targetPort: 80 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: pomosimple +spec: + replicas: 1 + selector: + matchLabels: + app: pomosimple + template: + metadata: + labels: + app: pomosimple + spec: + containers: + - name: pomosimple + image: idjohnson/pomonginx:latest + ports: + - containerPort: 80 +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: pomosimple + annotations: + cert-manager.io/cluster-issuer: YOURCLUSTERISSUER + kubernetes.io/ingress.class: nginx + kubernetes.io/tls-acme: "true" + ingress.kubernetes.io/ssl-redirect: "true" + nginx.ingress.kubernetes.io/ssl-redirect: "true" + nginx.org/websocket-services: pomosimple +spec: + rules: + - host: pomodoro.example.com + http: + paths: + - pathType: ImplementationSpecific + path: "/" + backend: + service: + name: pomosimple + port: + number: 80 + tls: + - hosts: + - pomodoro.example.com + secretName: pomosimple-tls