diff --git a/README.md b/README.md index 0eef793..e07d739 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,19 @@ An nginx proxy server that caches requests only when explicitly requested via the `X-Cache: 1` header. +## Quick Start + +```bash +# Build and run with docker-compose +docker-compose up --build + +# Or build with the build script +./build.sh + +# Then run the built image +docker run -p 3000:3000 docker.site.quack-lab.dev/nginx-cache-proxy:latest +``` + ## Configuration The nginx configuration implements an inverted caching logic: diff --git a/build.sh b/build.sh index 8df1c40..bd3e4d0 100644 --- a/build.sh +++ b/build.sh @@ -1,19 +1,19 @@ #!/bin/bash -  + # ============================================================================ # CONFIGURATION - Modify these for your project # ============================================================================ -  + # Docker registry and image name DOCKER_REPO="docker.site.quack-lab.dev" IMAGE_NAME="nginx-cache-proxy" -  + # ============================================================================ # VALIDATE CONFIGURATION # ============================================================================ echo "Validating nginx configuration..." -nginx -t -c /dev/stdin <<< "$(cat nginx.conf)" +docker run --rm -v "$(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro" nginx:alpine nginx -t if [ $? -ne 0 ]; then echo "Error validating nginx configuration" @@ -23,22 +23,22 @@ fi # ============================================================================ # DOCKER BUILD AND TAG # ============================================================================ -  + COMMIT_SHA=$(git rev-parse --short HEAD) IMAGE_BASE="${DOCKER_REPO}/${IMAGE_NAME}" -  + echo "" echo "Building Docker image..." docker build -t "${IMAGE_BASE}:${COMMIT_SHA}" . -  + if [ $? -ne 0 ]; then - echo "Error building agx Docker image" + echo "Error building nginx-cache-proxy Docker image" exit 1 fi -  + echo "Tagging as latest..." docker tag "${IMAGE_BASE}:${COMMIT_SHA}" "${IMAGE_BASE}:latest" -  + TAGS=$(git tag --points-at HEAD) if [ -n "$TAGS" ]; then echo "Found tags on current commit:" @@ -49,16 +49,16 @@ if [ -n "$TAGS" ]; then fi done <<< "$TAGS" fi -  + # ============================================================================ # PUSH IMAGES # ============================================================================ -  + echo "" echo "Pushing Docker images..." docker push "${IMAGE_BASE}:${COMMIT_SHA}" docker push "${IMAGE_BASE}:latest" -  + if [ -n "$TAGS" ]; then while IFS= read -r tag; do if [ -n "$tag" ]; then @@ -66,11 +66,11 @@ if [ -n "$TAGS" ]; then fi done <<< "$TAGS" fi -  + # ============================================================================ # SUMMARY # ============================================================================ -  + echo "" echo "Build complete! Image pushed as:" echo " - ${IMAGE_BASE}:${COMMIT_SHA}" @@ -82,6 +82,3 @@ if [ -n "$TAGS" ]; then fi done <<< "$TAGS" fi -  -  -  \ No newline at end of file