gin-rest-api-example
gin-rest-api-example copied to clipboard
Fix Docker build failure and configuration issues
- Update Dockerfile from Go 1.14 to Go 1.21-alpine
- Implement multi-stage build for smaller image size
- Add MySQL root password in docker-compose.yaml
- Fix article-server command path (article-server -> ./article-server)
- Add proper volume mount for config file (local.yaml -> config.yaml)
- Add depends_on to ensure MySQL starts before article-server
- Include build context and dockerfile specification
These changes resolve Docker build failures and runtime configuration errors."
Problem
- Docker build failed due to outdated Go version (1.14)
- Missing MySQL credentials in docker-compose
- Incorrect article-server command path
- Missing volume mounts for config and migrations
Solution
- Updated Dockerfile to use golang:1.21-alpine
- Added MySQL environment variables to docker-compose
- Fixed article-server command path
- Added volume mounts for config and migration files
- Added depends_on to ensure correct startup order
Testing
- Docker build completed successfully
- All containers running as expected
- Article server accessible on port 8080
- MySQL connection verified #Issue No. [#2]