go-sample

command module
v0.0.0-...-da572ff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2022 License: MIT Imports: 1 Imported by: 0

README

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

  1. Build container image
docker build -t go-simple:v01 . 
  1. Run container image
docker run --rm --name go-simple-app -p 8080:8080 -d go-simple:v01
  1. The application has two endpoints / and /ping
curl -X GET http://localhost:8080/
curl -X GET http://localhost:8080/ping
  1. 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.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL