Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile with gocron #175

Open
JoJoCoJo opened this issue Mar 30, 2023 · 1 comment
Open

Dockerfile with gocron #175

JoJoCoJo opened this issue Mar 30, 2023 · 1 comment

Comments

@JoJoCoJo
Copy link

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

@JohnRoesler
Copy link
Contributor

@JoJoCoJo Few things:

  1. This library is no longer maintained -> https://github.com/jasonlvhit/gocron#note-from-current-maintainers
  2. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants