Go simple HTTP server
Please inspect Dockerfile and apply best practices.
If you are new with Docker and Go, see and go through this page by docker official.
Read this page in other language: English, 日本語
How to build and run the application
- Build container image
docker build -t go-simple:v01 .
- Run container image
docker run --rm --name go-simple-app -p 8080:8080 -d go-simple:v01
- The application has two endpoints
/ and /ping
curl -X GET http://localhost:8080/
curl -X GET http://localhost:8080/ping
- Stop container
docker stop go-simple-app
Tasks
1. Minimize docker image size
Docker image size is over 1 GB.
2. Use non-root user for container process
Container process is using a root user.
3. Fix vulnerabilities
Container image has some vulnerabilities
Resolve all of the vulnerabilities.
Note: you can ignore some vulnerabilities for which the fix is not yet available.
4. Improve build time
Dockerfile or README.md are also copied to the container image.
Fix this problem so that they will not be included in the image.
When you edit the server.go file, the docker build will run go mod download again.
go mod download should be triggered only when go.mod has been updated.
Fix Dockerfile to improve the build speed.