Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Docker support. #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM debian:stable-slim AS build
# Install from package manager.
RUN apt update && \
apt install -y apt-transport-https ca-certificates curl gpg && \
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg && \
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list && \
apt update && apt install -y kubectl

# OR Install with curl.
# RUN apt update && \
# apt install -y curl && \
# curl -L "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -s -o /usr/bin/kubectl && \
# chmod +x /usr/bin/kubectl

FROM nginx:mainline-alpine3.18-slim
WORKDIR /root

COPY --from=build /usr/bin/kubectl /usr/bin/kubectl
COPY ./kubeconfig_tmp /root/.kube/config
COPY ./notlens.conf /etc/nginx/conf.d
COPY ./run.sh .
COPY ./index.html .

EXPOSE 8088

CMD [ "./run.sh" ]
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
start: build run

# IMAGE_NAME = notlens:$(shell git log --pretty=oneline --abbrev-commit -n 1 | awk '{print $1}')
IMAGE_NAME = notlens:v1

build:
@echo "building image..."
# copy kubeconfig to container, pls modify it if your config is not here.
cp ~/.kube/config ./kubeconfig_tmp
echo "server {\nlisten 8088;\nlocation / {\nproxy_pass http://127.0.0.1:8001;\n}\n}" > notlens.conf
echo "#!/usr/bin/env sh\nnohup kubectl proxy -w /root > /dev/null 2>&1 &\nnginx -g 'daemon off;'\n" > ./run.sh
chmod +x run.sh
docker build -t $(IMAGE_NAME) .
rm -fv ./kubeconfig_tmp ./notlens.conf ./run.sh

buildx:
@echo "build mutil-platform images..."
cp ~/.kube/config ./kubeconfig_tmp
echo "server {\nlisten 8088;\nlocation / {\nproxy_pass http://127.0.0.1:8001;\n}\n}" > notlens.conf
echo "#!/usr/bin/env sh\nnohup kubectl proxy -w /root > /dev/null 2>&1 &\nnginx -g 'daemon off;'\n" > ./run.sh
chmod +x run.sh
docker buildx build --platform linux/amd64,linux/arm/v7 -t mac2000/$(IMAGE_NAME) . --push
rm -fv ./kubeconfig_tmp ./notlens.conf ./run.sh

clean:
@echo "cleanning..."
rm -fv ./kubeconfig_tmp ./notlens.conf ./run.sh
docker rm -f notlens

run:
@echo "run container..."
docker run -d -p 8088:8088 --name notlens $(IMAGE_NAME)