Skip to content

Instantly share code, notes, and snippets.

@mbigras
Last active February 8, 2023 06:34
Show Gist options
  • Save mbigras/9e12a2027374569073eb979b17994f69 to your computer and use it in GitHub Desktop.
Save mbigras/9e12a2027374569073eb979b17994f69 to your computer and use it in GitHub Desktop.
Build mbigras/blueapp:v1 Docker image.
cat <<'Dockerfile' | docker build -t mbigras/blueapp:v1 -
# syntax=docker/dockerfile:1.3-labs see https://www.docker.com/blog/introduction-to-heredocs-in-dockerfiles/
FROM python
RUN pip install flask gunicorn
RUN cat <<App >app.py
import os
from flask import Flask, jsonify
app = Flask("blueapp")
@app.route("/")
def ui():
return jsonify(
color=os.environ["COLOR"],
corners=os.environ["CORNERS"],
widgets=os.environ["WIDGETS"],
)
App
ENV PORT=8080
ENTRYPOINT ["gunicorn", "app:app"]
Dockerfile
Run mbigras/blueapp:v1 Docker container.
docker run -it -p 8080:8080 -e COLOR=blue -e CORNERS=rounded -e WIDGETS=w1,w2,w3 mbigras/blueapp:v1
$ curl localhost:8080
{"color":"blue","corners":"rounded","widgets":"w1,w2,w3"}
apiVersion: apps/v1
kind: Deployment
metadata:
name: blueapp
spec:
selector:
matchLabels:
app: blueapp
replicas: 3
template:
metadata:
labels:
app: blueapp
spec:
containers:
- name: blueapp
image: mbigras/blueapp:v1
envFrom:
- configMapRef:
name: blueapp
kind: Kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
resources:
- deployment.yaml
configMapGenerator:
- name: blueapp
literals:
- COLOR=cornflowerblue
- CORNERS=rounded
- WIDGETS=w2,w1,w3
@mbigras
Copy link
Author

mbigras commented Feb 8, 2023

This gist is for kubernetes/kubectl#686 (comment) comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment