Sign inSign up

mokiat/gocrane

By mokiat

•Updated 6 months ago

GoCrane is a tool to help run and automatically rebuild Go applications in a Docker environment.

Image
0

1.3K

mokiat/gocrane repository overview

GoCrane is a tool to help run and automatically rebuild Go applications in a Docker environment.

You can have a dedicated Dockerfile for local development that can look as follows:

FROM mokiat/gocrane:latest AS gocrane

FROM golang:1.21
COPY --from=gocrane /bin/gocrane /bin/gocrane
COPY . /src/project
WORKDIR /src/project

ENV GOCRANE_MAIN='./cmd/example'
ENV GOCRANE_BINARY='/bin/example'
RUN gocrane build

CMD ["gocrane", "run"]

You need to adjust ./cmd/example to point to the main package of your project. There are more flags (or env variables) that can be configured to fine-tune how an app is watched, built and started but the basic setup above should be a good starting point for most projects.

Next, you can start a docker container as follows:

docker run -it --rm -d -v './:/src/project' 'example:latest'

Alternatively, you could use Docker Compose to orchastrate multiple projects backed by GoCrane.

version: '3.8'

services:
  example:
    build: ./
    image: "example:latest"
    volumes:
      - "./:/src/project"

The key part here is that the project's source code is mounted to the correct folder inside the container.

You can check the example⁠ directory of the official source code⁠ for a working example.

Tag summary

Content type

Image

Digest

sha256:ad0e23422…

Size

7.2 MB

Last updated

6 months ago

docker pull mokiat/gocrane