From c4974c07288bdce9a25dc8e73e5b2732e05f973c Mon Sep 17 00:00:00 2001 From: SeongChan Lee Date: Wed, 24 Jul 2024 15:39:16 +0900 Subject: [PATCH] Add skaffold to tighten local development loop --- .dockerignore | 2 -- .github/workflows/ci.yaml | 5 ++++- .gitignore | 3 +++ docker/build.Dockerfile | 11 +++++++++++ docker/build.Dockerfile.dockerignore | 16 ++++++++++++++++ Dockerfile => docker/skaffold.Dockerfile | 7 ++++++- docker/skaffold.Dockerfile.dockerignore | 18 ++++++++++++++++++ skaffold.yaml | 24 ++++++++++++++++++++++++ 8 files changed, 82 insertions(+), 4 deletions(-) delete mode 100644 .dockerignore create mode 100644 docker/build.Dockerfile create mode 100644 docker/build.Dockerfile.dockerignore rename Dockerfile => docker/skaffold.Dockerfile (75%) create mode 100644 docker/skaffold.Dockerfile.dockerignore create mode 100644 skaffold.yaml diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 96ef862..0000000 --- a/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -target/ -.idea/ diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2585f0a..f04bad4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -62,7 +62,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: docker build --tag "pod-graceful-drain:latest" . + - run: | + docker build --file docker/build.Dockerfile \ + --tag "pod-graceful-drain:latest" \ + . - run: docker image save --output pod-graceful-drain.tar pod-graceful-drain - uses: actions/upload-artifact@v4 with: diff --git a/.gitignore b/.gitignore index 96ef862..d543f60 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ +.venv/ + target/ + .idea/ diff --git a/docker/build.Dockerfile b/docker/build.Dockerfile new file mode 100644 index 0000000..1887c7a --- /dev/null +++ b/docker/build.Dockerfile @@ -0,0 +1,11 @@ +FROM rust:1.79-slim-bookworm as builder +RUN apt-get update && apt-get install -y git +RUN mkdir /src +WORKDIR /src +COPY . /src/ +RUN cargo install --path . + +FROM debian:bookworm-slim +WORKDIR /app +COPY --from=builder /usr/local/cargo/bin/pod-graceful-drain /app/pod-graceful-drain +ENTRYPOINT ["/app/pod-graceful-drain"] diff --git a/docker/build.Dockerfile.dockerignore b/docker/build.Dockerfile.dockerignore new file mode 100644 index 0000000..9fea67c --- /dev/null +++ b/docker/build.Dockerfile.dockerignore @@ -0,0 +1,16 @@ +/.github/ +/charts/ +/tests/ +/.gitignore +/LICENSE +/README.md +/.python-version +/pyproject.toml +/requirements.lock +/requirements-dev.lock +/skaffold.yaml + +/target/ +/.venv/ + +/.idea/ diff --git a/Dockerfile b/docker/skaffold.Dockerfile similarity index 75% rename from Dockerfile rename to docker/skaffold.Dockerfile index b3d1eb6..c89f974 100644 --- a/Dockerfile +++ b/docker/skaffold.Dockerfile @@ -4,8 +4,13 @@ WORKDIR /src COPY ./Cargo.* /src/ RUN cargo fetch --verbose -FROM fetch as builder +FROM rust:1.79-slim-bookworm as git RUN apt-get update && apt-get install -y git + +FROM git as builder +RUN mkdir /src +WORKDIR /src +COPY --from=fetch /src/ /src/ COPY . /src/ RUN cargo install --path . diff --git a/docker/skaffold.Dockerfile.dockerignore b/docker/skaffold.Dockerfile.dockerignore new file mode 100644 index 0000000..686b80b --- /dev/null +++ b/docker/skaffold.Dockerfile.dockerignore @@ -0,0 +1,18 @@ +/.git/ +/.github/ +/charts/ +/tests/ +/.gitignore +/LICENSE +/README.md +/.python-version +/pyproject.toml +/requirements.lock +/requirements-dev.lock +/skaffold.yaml + +/target/ +/.venv/ + +/.idea/ + diff --git a/skaffold.yaml b/skaffold.yaml new file mode 100644 index 0000000..bfdad79 --- /dev/null +++ b/skaffold.yaml @@ -0,0 +1,24 @@ +# skaffold is just to help tighten the local development/test loop +apiVersion: skaffold/v4beta11 +kind: Config +metadata: + name: pod-graceful-drain +build: + artifacts: + - image: ghcr.io/foriequal0/pod-graceful-drain + docker: + dockerfile: docker/skaffold.Dockerfile + context: . + local: + push: false + useBuildkit: true + concurrency: 0 +deploy: + helm: + releases: + - name: pod-graceful-drain + chartPath: charts/pod-graceful-drain + valuesFiles: + - charts/pod-graceful-drain/values.yaml + setValues: + experimentalGeneralIngress: true \ No newline at end of file