Skip to content

feat: add Docker configuration for consistent test environment#2

Merged
wenderson-me merged 3 commits into
mainfrom
fix/pact-contract-tests
Jan 16, 2026
Merged

feat: add Docker configuration for consistent test environment#2
wenderson-me merged 3 commits into
mainfrom
fix/pact-contract-tests

Conversation

@wenderson-me

Copy link
Copy Markdown
Owner

Descrição

Adiciona configuração Docker para ambiente de testes consistente e atualiza documentação.

Alterações

  • Dockerfile - Imagem otimizada com Node.js 20-slim
  • docker-compose.yml - Serviços para testes (all, consumer, provider, dev)
  • .dockerignore - Exclusão de arquivos desnecessários
  • README.md - Documentação dos comandos Docker

Comandos Docker disponíveis

# Executar todos os testes
docker compose run --rm tests

# Executar apenas testes do consumer
docker compose run --rm consumer-tests

# Executar apenas testes do provider
docker compose run --rm provider-tests

# Ambiente de desenvolvimento interativo
docker compose run --rm dev

Testes

  • ✅ Consumer tests: 3/3 passando
  • ✅ Provider tests: 1/1 passando (3 interações verificadas)
  • ✅ Build Docker: ~2.7 min

- Executar testes em Node.js 18.x e 20.x
- Rodar consumer e provider tests
- Upload dos arquivos pact como artefatos
Copilot AI review requested due to automatic review settings January 16, 2026 21:39
@wenderson-me wenderson-me merged commit ca68c97 into main Jan 16, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Docker configuration to enable consistent testing environments across different development machines. It introduces containerized test execution while maintaining compatibility with existing local development workflows.

Changes:

  • Added Docker configuration with optimized Node.js 20-slim image and native build dependencies
  • Created docker-compose services for running all tests, consumer-only tests, provider-only tests, and an interactive development environment
  • Added comprehensive .dockerignore to exclude unnecessary files from Docker builds
  • Added GitHub Actions workflow for automated contract testing on CI/CD
  • Updated README with Docker usage instructions

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Dockerfile Defines optimized container image with Node.js 20-slim, build dependencies, and test directory structure
docker-compose.yml Configures four services (tests, consumer-tests, provider-tests, dev) with appropriate volume mounts and commands
.dockerignore Excludes unnecessary files (node_modules, IDE configs, Docker files, documentation) from Docker builds
README.md Documents Docker commands for running tests and development environment
.github/workflows/pact-tests.yml Adds CI/CD workflow for automated contract testing using Node.js 20.x

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Dockerfile
RUN mkdir -p __tests__/contract/logs __tests__/contract/pacts

EXPOSE 8081 8082 8083
CMD ["npm", "test"]

Copilot AI Jan 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CMD references "npm test" but there is no "test" script defined in package.json. The available scripts are "test:consumer" and "test:provider". Consider either adding a "test" script to package.json that runs both test commands, or update this CMD to match an existing script like "test:consumer".

Suggested change
CMD ["npm", "test"]
CMD ["npm", "run", "test:consumer"]

Copilot uses AI. Check for mistakes.
on:
push:
branches: [main]
branches: [main, fix/pact-contract-tests]

Copilot AI Jan 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow is configured to run on push to branch 'fix/pact-contract-tests', which appears to be a feature/fix branch. For a production workflow, this branch should likely be removed from the trigger list after the PR is merged, leaving only 'main'.

Suggested change
branches: [main, fix/pact-contract-tests]
branches: [main]

Copilot uses AI. Check for mistakes.
Comment thread README.md

### Docker 🐳

```ruby

Copilot AI Jan 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code block is incorrectly marked as 'ruby' when it contains bash/shell commands. Change the language identifier from 'ruby' to 'bash' or 'sh' for proper syntax highlighting.

Copilot uses AI. Check for mistakes.
Comment thread docker-compose.yml
Comment on lines +4 to +28
container_name: pact-tests
volumes:
- ./src:/app/src:ro
- ./__tests__:/app/__tests__
command: sh -c "npm run test:consumer && npm run test:provider"

consumer-tests:
build: .
container_name: pact-consumer-tests
volumes:
- ./src:/app/src:ro
- ./__tests__:/app/__tests__
command: npm run test:consumer

provider-tests:
build: .
container_name: pact-provider-tests
volumes:
- ./src:/app/src:ro
- ./__tests__:/app/__tests__
command: npm run test:provider

dev:
build: .
container_name: pact-dev

Copilot AI Jan 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using fixed container_name with 'docker compose run' can cause conflicts if multiple instances are run concurrently. Since the README suggests using 'docker compose run --rm', which creates temporary containers, the container_name directives will prevent running multiple instances simultaneously. Consider removing container_name for all services to allow parallel execution, or document that only one instance can run at a time.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants