Skip to content

Commit

Permalink
trying multi stage builds maybe properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Storey committed Aug 6, 2024
1 parent af444a3 commit 9ae8b98
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker-build-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
context: .
push: false
load: false
platforms: linux/amd64,linux/arm64,linux/x86_64,linux/arm64/v8
platforms: linux/amd64,linux/arm64,linux/arm64/v7
tags: my-image:latest
cache-from: type=gha
cache-to: type=gha,mode=max
Expand All @@ -51,7 +51,7 @@ jobs:
with:
context: .
push: true
platforms: linux/amd64,linux/arm64,linux/x86_64,linux/arm64/v8
platforms: linux/amd64,linux/arm64,linux/arm64/v7
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/ttyd-k9s:${{ github.ref_name }}
${{ secrets.DOCKERHUB_USERNAME }}/ttyd-k9s:latest
Expand Down
40 changes: 33 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
FROM derailed/k9s:v0.32.4 AS k9s
FROM --platform=${BUILDPLATFORM} tsl0922/ttyd:latest as ttyd
ARG TARGETPLATFORM
ARG KUBECTL_VERSION="v1.29.0"

# Install necessary packages
RUN apt-get update && apt-get install -y \
curl \
wget \
git \
apt-transport-https \
gnupg2 \
&& rm -rf /var/lib/apt/lists/*


# linux/amd64, linux/arm64, linux/x86_64,linux/arm64/v8
# Install k9s
RUN case ${TARGETPLATFORM} in \
"linux/amd64") K9S_ARCH=amd64 ;; \
"linux/arm64") K9S_ARCH=arm64 ;; \
"linux/arm/v7") K9S_ARCH=armv7 ;; \
esac \
&& wget https://github.com/derailed/k9s/releases/download/v0.32.5/k9s_Linux_${K9S_ARCH}.tar.gz \
&& tar -xzf k9s_Linux_${K9S_ARCH}.tar.gz \
&& mv k9s /usr/local/bin/ \
&& rm k9s_Linux_arm64.tar.gz

# Install kubectl
RUN TARGET_ARCH=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) \
&& curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/${TARGET_ARCH}/kubectl -o /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl



FROM tsl0922/ttyd:alpine
COPY --from=k9s /bin/k9s /bin/k9s
COPY --from=k9s /usr/local/bin/kubectl /usr/local/bin/kubectl

# Create .kube directory
RUN mkdir -p /root/.kube

# Set working directory
WORKDIR /root

# Start ttyd with k9s
CMD ["ttyd", "--writable", "/bin/k9s"]
CMD ["ttyd", "--writable", "k9s"]

0 comments on commit 9ae8b98

Please sign in to comment.