diff --git a/Dockerfile.adapter-with-plugins b/Dockerfile.adapter-with-plugins new file mode 100644 index 0000000..926e112 --- /dev/null +++ b/Dockerfile.adapter-with-plugins @@ -0,0 +1,32 @@ +FROM golang:1.24-bullseye AS builder + +WORKDIR /workspace/app + +# Specifically copy only the necessary files and directories +COPY cmd/adapter/ ./cmd/adapter/ +COPY core/ ./core/ +COPY pkg/ ./pkg/ +COPY install/build-plugins.sh ./install/build-plugins.sh +COPY go.mod . +COPY go.sum . + +RUN go mod download + +# Build main server +RUN go build -o server cmd/adapter/main.go + +# Make the build script executable and run it to build plugins +RUN chmod +x install/build-plugins.sh && \ + ./install/build-plugins.sh + +# Create minimal runtime image +FROM cgr.dev/chainguard/wolfi-base +WORKDIR /app + +# Copy binary and plugins built with same Go version +COPY --from=builder /workspace/app/server . +COPY --from=builder /workspace/app/plugins ./plugins + +EXPOSE 8081 + +CMD ["sh", "-c", "./server --config=${CONFIG_FILE}"] diff --git a/README.md b/README.md index bd4f7f4..2c2a083 100644 --- a/README.md +++ b/README.md @@ -205,23 +205,28 @@ This automated script will: - Start ONIX adapter in Docker - Create environment configuration -**Note:** Extract schemas before running: `unzip schemas.zip` (required for schema validation) +**Note:** Extract schemas before running: `unzip schemas.zip` (required for schema validation) and before running the automated setup, build the adapter image ,update docker-compose-adapter2.yaml to use the correct image +```bash +# from the repository root +docker build -f Dockerfile.adapter-with-plugins -t beckn-onix:latest . +``` **Services Started:** - Redis: localhost:6379 - ONIX Adapter: http://localhost:8081 ### Docker Deployment +**Note:** Start redis before before running onix adapter. + ```bash # Build the Docker image -docker build -f Dockerfile.adapter -t beckn-onix:latest . + docker build -t beckn-onix:latest -f Dockerfile.adapter-with-plugins . # Run the container docker run -p 8081:8081 \ -v $(pwd)/config:/app/config \ -v $(pwd)/schemas:/app/schemas \ - -v $(pwd)/plugins:/app/plugins \ -e CONFIG_FILE="/app/config/local-simple.yaml" \ beckn-onix:latest ``` diff --git a/SETUP.md b/SETUP.md index cbe9f10..aa59ee1 100644 --- a/SETUP.md +++ b/SETUP.md @@ -88,7 +88,12 @@ This will automatically: **Key Management:** Uses `simplekeymanager` with embedded keys - no Vault setup required! -**Note:** Extract schemas before running: `unzip schemas.zip` (required for schema validation) +**Note:** Extract schemas before running: `unzip schemas.zip` (required for schema validation) and before running the automated setup, build the adapter image ,update docker-compose-adapter2.yaml to use the correct image + +```bash +# from the repository root +docker build -f Dockerfile.adapter-with-plugins -t beckn-onix:latest . +``` ### Option 2: Complete Beckn Network @@ -120,12 +125,17 @@ This will automatically: - ONIX Adapter: http://localhost:8081 - Redis: localhost:6379 -**Note:** Extract schemas before running: `unzip schemas.zip` (required for schema validation) +**Note:** Extract schemas before running: `unzip schemas.zip` (required for schema validation) and before running the automated full-network setup, build the adapter image , update docker-compose-adapter2.yaml to use the correct image + +```bash +# from the repository root +docker build -f Dockerfile.adapter-with-plugins -t beckn-onix:latest . +``` **Intelligent Key Management:** The script reads `docker-compose-adapter2.yml` to detect which config file is being used (default: `local-simple.yaml`), extracts keys from protocol server configs, and automatically updates the `simplekeymanager` section in that config file - no manual configuration needed! -**Note:** Update `docker-compose-adapter2.yml` to use the correct config file: +**Note:** Update `docker-compose-adapter2.yml` to use the correct config file and correct image: - For combined setup (simplekeymanager): `CONFIG_FILE: "/app/config/local-simple.yaml"` - For combined setup (keymanager with Vault): `CONFIG_FILE: "/app/config/local-dev.yaml"` - For combined setup (production): `CONFIG_FILE: "/app/config/onix/adapter.yaml"`