From 19a5c3ae83eec8497c2bd649cffb8826b93436f6 Mon Sep 17 00:00:00 2001 From: thund3rbird-17 <1ds23cd034@dsce.edu.in> Date: Thu, 8 Jan 2026 23:04:30 +0530 Subject: [PATCH] feat: add Docker and docker-compose support for S3-Keploy - Add Dockerfile with multi-stage build (golang:1.21-alpine + alpine:3.18) - Add docker-compose.yml with AWS credentials volume mount - Update README.md with comprehensive Docker setup instructions - Includes ca-certificates for HTTPS connections to AWS S3 - Exposes port 3000 for the Fiber application - Follows repository conventions from other quickstarts Tested: - Docker build succeeds (22.1MB optimized image) - docker-compose up starts application successfully - Application connects to AWS S3 and API endpoints work - Port 3000 accessible and Fiber server running Fixes #3505 Signed-off-by: thund3rbird-17 <1ds23cd034@dsce.edu.in> --- S3-Keploy/Dockerfile | 15 ++++++++++++ S3-Keploy/README.md | 47 +++++++++++++++++++++++++++++++++++- S3-Keploy/docker-compose.yml | 17 +++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 S3-Keploy/Dockerfile create mode 100644 S3-Keploy/docker-compose.yml diff --git a/S3-Keploy/Dockerfile b/S3-Keploy/Dockerfile new file mode 100644 index 00000000..c52a60d2 --- /dev/null +++ b/S3-Keploy/Dockerfile @@ -0,0 +1,15 @@ +# Multi-stage build for optimized image size +FROM golang:1.21-alpine AS builder +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN CGO_ENABLED=0 GOOS=linux go build -o app . + +# Final stage - runtime image +FROM alpine:3.18 +WORKDIR /app +RUN apk --no-cache add ca-certificates +COPY --from=builder /app/app . +EXPOSE 3000 +CMD ["./app"] diff --git a/S3-Keploy/README.md b/S3-Keploy/README.md index 3241a22a..27147c41 100644 --- a/S3-Keploy/README.md +++ b/S3-Keploy/README.md @@ -6,8 +6,53 @@ A simple CRUD application to showcase Keploy integration capabilities using [Go- 1. [Go](https://go.dev/doc/install) 2. [AWS Access Key and Security Key](https://aws.github.io/aws-sdk-go-v2/docs/getting-started/#get-your-aws-access-keys) +3. [Docker](https://docs.docker.com/engine/install/) (optional, for containerized deployment) -## Running app on Ubuntu 22.04.03 LTS +## Running app using Docker + +Keploy can be used on Linux, Windows and MacOS through [Docker](https://docs.docker.com/engine/install/). + +> Note: To run Keploy on MacOS through [Docker](https://docs.docker.com/desktop/release-notes/#4252) the version must be ```4.25.2``` or above. + +### Setting aws credentials + +Before running the app, ensure you have AWS credentials configured in your home directory: + +```bash +mkdir -p ~/.aws +cat > ~/.aws/credentials << EOF +[default] +aws_access_key_id = +aws_secret_access_key = +EOF +``` + +### Setup and build the application + +```bash +git clone https://github.com/keploy/samples-go.git && cd samples-go/S3-Keploy +docker build -t s3-keploy-app:1.0 . +``` + +### Using docker-compose + +Alternatively, you can use docker-compose to run the application: + +```bash +# Create the external network if it doesn't exist +docker network create keploy-network + +# Start the application +docker-compose up +``` + +### Capture the Testcases + +```shell +keploy record -c "docker run -p 3000:3000 --name s3KeployApp --network keploy-network -v ~/.aws:/root/.aws:ro s3-keploy-app:1.0" +``` + +## Running app on Ubuntu 22.04.03 LTS (without Docker) ### Setting aws credentials diff --git a/S3-Keploy/docker-compose.yml b/S3-Keploy/docker-compose.yml new file mode 100644 index 00000000..e98e1612 --- /dev/null +++ b/S3-Keploy/docker-compose.yml @@ -0,0 +1,17 @@ +version: "3.9" +services: + go-app: + build: + context: . + container_name: s3KeployApp + ports: + - "3000:3000" + volumes: + # Mount AWS credentials from host machine + - ~/.aws:/root/.aws:ro + networks: + - keploy-network + +networks: + keploy-network: + external: true