Skip to content

Commit 19a5c3a

Browse files
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>
1 parent f2c15ef commit 19a5c3a

3 files changed

Lines changed: 78 additions & 1 deletion

File tree

S3-Keploy/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Multi-stage build for optimized image size
2+
FROM golang:1.21-alpine AS builder
3+
WORKDIR /app
4+
COPY go.mod go.sum ./
5+
RUN go mod download
6+
COPY . .
7+
RUN CGO_ENABLED=0 GOOS=linux go build -o app .
8+
9+
# Final stage - runtime image
10+
FROM alpine:3.18
11+
WORKDIR /app
12+
RUN apk --no-cache add ca-certificates
13+
COPY --from=builder /app/app .
14+
EXPOSE 3000
15+
CMD ["./app"]

S3-Keploy/README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,53 @@ A simple CRUD application to showcase Keploy integration capabilities using [Go-
66

77
1. [Go](https://go.dev/doc/install)
88
2. [AWS Access Key and Security Key](https://aws.github.io/aws-sdk-go-v2/docs/getting-started/#get-your-aws-access-keys)
9+
3. [Docker](https://docs.docker.com/engine/install/) (optional, for containerized deployment)
910

10-
## Running app on Ubuntu 22.04.03 LTS
11+
## Running app using Docker
12+
13+
Keploy can be used on Linux, Windows and MacOS through [Docker](https://docs.docker.com/engine/install/).
14+
15+
> 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.
16+
17+
### Setting aws credentials
18+
19+
Before running the app, ensure you have AWS credentials configured in your home directory:
20+
21+
```bash
22+
mkdir -p ~/.aws
23+
cat > ~/.aws/credentials << EOF
24+
[default]
25+
aws_access_key_id = <YOUR_ACCESS_KEY_ID>
26+
aws_secret_access_key = <YOUR_SECRET_ACCESS_KEY>
27+
EOF
28+
```
29+
30+
### Setup and build the application
31+
32+
```bash
33+
git clone https://github.com/keploy/samples-go.git && cd samples-go/S3-Keploy
34+
docker build -t s3-keploy-app:1.0 .
35+
```
36+
37+
### Using docker-compose
38+
39+
Alternatively, you can use docker-compose to run the application:
40+
41+
```bash
42+
# Create the external network if it doesn't exist
43+
docker network create keploy-network
44+
45+
# Start the application
46+
docker-compose up
47+
```
48+
49+
### Capture the Testcases
50+
51+
```shell
52+
keploy record -c "docker run -p 3000:3000 --name s3KeployApp --network keploy-network -v ~/.aws:/root/.aws:ro s3-keploy-app:1.0"
53+
```
54+
55+
## Running app on Ubuntu 22.04.03 LTS (without Docker)
1156

1257
### Setting aws credentials
1358

S3-Keploy/docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: "3.9"
2+
services:
3+
go-app:
4+
build:
5+
context: .
6+
container_name: s3KeployApp
7+
ports:
8+
- "3000:3000"
9+
volumes:
10+
# Mount AWS credentials from host machine
11+
- ~/.aws:/root/.aws:ro
12+
networks:
13+
- keploy-network
14+
15+
networks:
16+
keploy-network:
17+
external: true

0 commit comments

Comments
 (0)