diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7aa8c5b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: CI - Build and Test Docker Compose + +on: + push: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and run containers + run: | + docker compose build + docker compose up -d + + - name: Check running containers + run: docker ps + + - name: Stop containers + run: docker compose down + + deploy: + needs: build + runs-on: ubuntu-latest + if: success() + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Login to Docker Hub + run: | + echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + + - name: Build and push Docker image + run: | + docker build -t eldordevops/express-redis-docker:latest . + docker push eldordevops/express-redis-docker:latest diff --git a/README.md b/README.md index adee4eb..5b376d6 100644 --- a/README.md +++ b/README.md @@ -24,3 +24,4 @@ curl http://localhost:3000/store/my-key\?some\=value\&some-other\=other-value ```sh curl http://localhost:3000/my-key ``` +# test workflow Mon Nov 3 04:40:21 PM +05 2025 diff --git a/docker-compose.yml b/docker-compose.yml index 8adc9dc..5682b80 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,20 +1,23 @@ -redis: - image: redis - container_name: cache - expose: - - 6379 -app: - build: ./ - volumes: - - ./:/var/www/app - links: - - redis - ports: - - 3000:3000 - environment: - - REDIS_URL=redis://cache - - NODE_ENV=development - - PORT=3000 - command: - sh -c 'npm i && node server.js' +version: "3.8" +services: + redis: + image: redis + container_name: cache + expose: + - 6379 + + app: + build: ./ + volumes: + - ./:/var/www/app + links: + - redis + ports: + - "3000:3000" + environment: + - REDIS_URL=redis://cache + - NODE_ENV=development + - PORT=3000 + command: > + sh -c 'npm i && node server.js'