Golang revel framework hot-reload in docker environment

1k views Asked by At

I'm trying to set up golang environment as described in this great post. I'm using Docker on OS X 10.10 with boot2docker (v1.3.0) and fig.sh (1.0.1). Everything runs fine, but revel's hot-reload not working at all. Anyone experienced same problem or know any workaround to make hot-reload work? Revel framework version 0.11.1

2

There are 2 answers

0
ptman On

Boot2docker uses VirtualBox, and I'm assuming vboxsf for shared folders. vboxsf doesn't notify about changed files. Try keeping the files completely inside the virtual machine. Does that help?

0
Eutychus On

How about something like this for a Dockerfile

FROM golang:1.17.2-alpine AS build

# Add required packages
RUN apk add --update git curl bash

# Install revel framework
RUN go get -u github.com/revel/revel
RUN go get -u github.com/revel/cmd/revel

WORKDIR /app

COPY go.mod go.sum ./
RUN go mod download

ENV CGO_ENABLED 0

ADD . .

ENTRYPOINT revel run

Then run using something like docker compose:

version: '3.9'

services:
  go-revel-crud:
    build:
      context: .
      dockerfile: ./Dockerfile.local
    ports:
      - 8090:8090
    volumes:
      - .:/app
    environment:
      - ENV=dev
      - PORT=8090

Mounting the volume for current directory to the working dir /app.

Checkout this guide with full explaination