How to deploy static templates with GO (GOLANG)

Oh! You’ll need to remove the [build] block entirely to get the Dockerfile to work.

The Dockerfile defines what to include in the build. Buildpacks are like enhanced dockerfiles that are a little more opaque and magical. So what’s happening in that Dockerfile I gave you is:


# this copies the binary from the build step
COPY --from=builder /go/src/app/app /goapp/app

# this adds everything to the image
COPY . /throwaway

# this copies the resources directory if it exists
RUN cp -r /throwaway/resources ./resources || echo "No resources to copy"

# this removes everything else so you're left with binary + resources
RUN rm -rf /throwaway

Dockerfiles are kind of a pain to write and keep lean, but they are reasonably straightforward to read.