mahdi gadget
mahdi gadget

Reputation: 113

no Go files in /usr/local/go/src

I get the following error when I run the docker-compose.

 > [4/4] RUN go build -o ./main:
#0 3.000 package database: no Go files in /usr/local/go/src/database

this is my Dockerfile:

FROM golang:1.18.2-alpine
COPY . /appDatabase
WORKDIR /appDatabase

RUN go build -o ./main

CMD [ "./main" ]

And this is a part of my docker-compose

  database_runner:
    container_name:   databaseRunner
    hostname:   databaseRunner
    build:
      context: .
      dockerfile: Dockerfile
    networks:
      - database

All my files are inside database project

I want the database configuration file to be executed after running the postgres container, but I am facing a problem, thank you in advance for your help.

Upvotes: 0

Views: 717

Answers (1)

mahdi gadget
mahdi gadget

Reputation: 113

I tried several methods and finally by changing the Dockerfile, my problem was solved

FROM golang:1.18.2-alpine
WORKDIR /appDatabase
COPY . /appDatabase

RUN go build main.go


CMD [ "./main" ]

Upvotes: 1

Related Questions