Skip to content
The Chat Archive
gpt-3.5-turbo-0613· OpenAI WildChat-4.8M (AI2)

FROM golang:1.21-alpine RUN apk update RUN apk add make RUN make build RUN .…

  1. User

    FROM golang:1.21-alpine

    RUN apk update RUN apk add make

    RUN make build

    RUN . ./test_env.sh

    WORKDIR /bin/public/

    EXPOSE 8085

    CMD [". /s2s"]

    this Dockerfile with docker-compose file version: '3.8'

    services: auth-service: container_name: auth-service build: context: auth-service/ dockerfile: ../Dockerfile ports: - "8085:8085"

    produce error

    [auth-service 4/6] RUN make build: 0.344 make: *** No rule to make target 'build'. Stop. how can i fix it?

  2. Assistant

    The error message suggests that there is no rule defined in your Makefile for the target build. To fix this, you need to create a Makefile in the auth-service directory that includes a rule for building your project.

    Here's an example of how your Makefile could look:

    build:
        go build -o s2s
    
    test:
        go test ./...
    
    .PHONY: build test
    

    Make sure to place this Makefile in the same directory as your Dockerfile, or update the Dockerfile accordingly.

    Additionally, you can modify your Dockerfile to copy the Makefile into the container and then run make build:

    FROM golang:1.21-alpine
    
    RUN apk update
    RUN apk add make
    
    WORKDIR /app
    
    COPY Makefile .
    RUN make build
    
    COPY . .
    
    RUN . ./test_env.sh
    
    WORKDIR /bin/public/
    
    EXPOSE 8085
    
    CMD ["/s2s"]
    

    This Dockerfile assumes that your project files are located in the current directory. Adjust the COPY command accordingly if they are located elsewhere.

    After making these changes, your Docker build command should be successful.