I'm working on a Go service with Docker, and thinking that as it is compiled, to deploy code in production, I just need the docker compose, and the Docker image published on my registry.
As I come from PHP world, I am used to clone my whole project to deploy it.
Is there any way I could deploy my project only with docker-compose file ?
I saw on this post that I can git clone only a single file, but it feels that it is not a good way to do, what is the best practice to deploy a Go Microservice with Docker ?
There are two separate problems in your question, and I am not sure which ones you're looking for an answer for.
Q1: What's a good way to create a Dockerfile for my Go project A1: Have a look at the example here: https://docs.docker.com/develop/develop-images/multistage-build/. If you need to git clone, clone the entire source tree, as you would with php...
Q2: Now that I have my image, how do I use it in production. A2: Make sure it's available on a repository (public or private) somewhere. Then reference that image (using it's full name, which includes the FQDN of the repo server, if you aren't using Docker Hub) when starting your container. There's no need to "git clone" anything at this point...