go mod init go-http-server
to set up your project and manage its dependencies.main.go
and add the following code to set up a basic http server using the
gin web framework.go mod download
command to download the required dependencies.go run main.go
to start the server..dockerignore
file and add that contents that should not be copied over
to the docker file system.
.dockerinogre
file and adding folders like node_modules
is must, since dependencies will be installed
while building the image based on the platform preferences used. Copying those from file system will overwrite the
installed dependencies and might fail during deploymentssource code
and build and run it inside the container. You can opt for multi stage build, if you want to
build the go binary in build stage and run it in another stage.
go-http-server
image for platform linux/amd64
.
If you are locally testing your application, you can skip the platform
key to build the images