Skip to content

Commit

Permalink
Update the code to run in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
ranjith-ka committed Oct 13, 2024
1 parent 2b02528 commit 56cda16
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 4 deletions.
44 changes: 43 additions & 1 deletion .zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,46 @@ alias k_svc_all='kubectl get svc --all-namespaces'
alias k_svc='kubectl get svc'
alias k_ds_po='kube_desc_pod'
alias k_login="kdex-fn"
alias k_busybox='kubectl run -i --tty busybox --image=busybox --restart=Never -- /bin/sh; kubectl delete pod busybox'
alias k_busybox='kubectl run -i --tty busybox --image=busybox --restart=Never -- /bin/sh; kubectl delete pod busybox'

dive_image() {
local IMAGE_NAME="${1}"
local TMP_FILE=/tmp/dive-tmp-image.tar
docker save "$IMAGE_NAME" > $TMP_FILE && dive $TMP_FILE --source=docker-archive && rm $TMP_FILE
}

# Function to remove all "exited" containers
remove_exited_containers() {
local exited_containers=$(docker ps -a -f status=exited -q)
if [ -n "$exited_containers" ]; then
docker rm $exited_containers
fi
}

# Function to remove all "created" containers
remove_created_containers() {
local created_containers=$(docker ps -a -f status=created -q)
if [ -n "$created_containers" ]; then
docker rm $created_containers
fi
}

# Function to remove all stopped containers (both "exited" and "created")
remove_stopped_containers() {
docker container prune -f
}

# Function to remove all untagged images
remove_untagged_images() {
local untagged_images=$(docker images -f "dangling=true" -q)
if [ -n "$untagged_images" ]; then
docker rmi $untagged_images
fi
}

cleanup_docker() {
remove_exited_containers
remove_created_containers
remove_stopped_containers
remove_untagged_images
}
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23 as builder
FROM golang:1.23-alpine AS builder

ARG APP

Expand All @@ -11,7 +11,7 @@ RUN go mod download
# Copy the source from the current directory to the Working Directory inside the container
COPY . .

RUN go build .
RUN go build -o Devops main.go

FROM alpine:3.14

Expand Down Expand Up @@ -39,4 +39,4 @@ COPY --from=builder --chown=user1:user1 /build/Devops /app/

EXPOSE 8080

ENTRYPOINT ["./Devops"]
ENTRYPOINT ["./Devops", "serve"]
20 changes: 20 additions & 0 deletions minikube/skaffold/01_skaffold.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,23 @@ It can be used to build, test, and deploy applications.
```bash
brew install skaffold
```

## skaffold dev

skaffold dev enables continuous local development on an application. While in dev mode, Skaffold will watch an application’s source files, and when it detects changes, will rebuild your images (or sync files to your running containers), push any new images, test built images, and redeploy the application to your cluster.

Dev Loop:

- File sync
- build
- Test
- Deploy

Skaffold also supports a polling mode where the filesystem is checked for changes on a configurable interval, or a manual mode, where Skaffold waits for user input to check for file changes. These watch modes can be configured through the --trigger flag.

## Debugging With Skaffold

### TODO

- [ ] Add debugging with Skaffold
- [ ] Steps for Golang and .NET Core

0 comments on commit 56cda16

Please sign in to comment.