Hi, I'm trying to dockerize my project and I need to install the gocron package, but when it's building the container returns me the next error:
no required module provides package github.com/jasonlvhit/gocron; to add it:
#0 1.228 go get github.com/jasonlvhit/gocron
I imported in my go file like this:
import (
"github.com/jasonlvhit/gocron"
)
And this is my Dockerfile config
FROM golang:1.20.2
# set working directory
WORKDIR /usr/src/app
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify
RUN go get github.com/jasonlvhit/gocron
# install gin for hot reloading
RUN go install github.com/codegangsta/gin@latest
# copy the source code
COPY . .
# build the binary
RUN go build -v -o /usr/local/bin/app ./...
# expose port 80
EXPOSE 80
# command to start the application with hot reloading
CMD gin -i -p 80 -a 8080 run app
When I installed on local enviroment works correctly, but I need to runs on docker :S
It looks like the dependency must not be in your go.mod as you're running go get inside the docker file. Instead, you'll want to add the dep to your go.mod outside of docker and run go mod tidy
Hi, I'm trying to dockerize my project and I need to install the gocron package, but when it's building the container returns me the next error:
I imported in my go file like this:
And this is my Dockerfile config
When I installed on local enviroment works correctly, but I need to runs on docker :S