Skip to content

Dockerfile with gocron #175

@JoJoCoJo

Description

@JoJoCoJo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions