Configure a fresh custom dev environnement

Hello :slight_smile:

I’m trying to configure a fresh dev environnement to work on my local machine. I tried to follow the official documentation and build a compose-dev.yaml file.

My root folder is as follow :

dev
  frontend
    DockerFile
compose-dev.yaml

My compose-dev.yaml file :

version: "3.7"
services:
  backend:
    build:
      context: backend
      target: development
    secrets:
      - db-password
    depends_on:
      - db
  db:
    image: mariadb
    restart: always
    healthcheck:
      test: [ "CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent" ]
      interval: 3s
      retries: 5
      start_period: 30s
    secrets:
      - db-password
    volumes:
      - db-data:/var/lib/mysql
    environment:
      - MYSQL_DATABASE=example
      - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db-password
    expose:
      - 3306
  proxy:
    build: proxy
    ports:
      - 8080:80
    depends_on:
      - backend
volumes:
  db-data:
secrets:
  db-password:
    file: db/password.txt

My Dockerfile :

FROM golang:1.16-alpine AS build
WORKDIR /go/src/github.com/org/repo
COPY . .
RUN go build -o server .
FROM build AS development
RUN apk update \
    && apk add git
CMD ["go", "run", "main.go"]
FROM alpine:3.12
EXPOSE 8000
COPY --from=build /go/src/github.com/org/repo/server /server
CMD ["/server"]

When I chose compose based dev environnement in docker desktop and select my local folder. It start to with : pulling image…

Then it says almost immediately starting container and it finishes very quickly.

When I open in vscode nothing is installed go no command found

Am I doing something wrong ?

Thank you for your help !

I don’t have time to test it more now, but I tried it. I have no idea how Docker Desktop would know which container you want to use to start only that. There are 3 services in the compose file, there is no frontend in it, but you only have frontend in your folder. The proxy service has no Dockerfile either. If it is really your actual setup, it shouldn’t start anything, yet you say you see “pulling images”. So my guess is it completely ignores the compose file and starts a default dev environment.

When I tried, I at least had a Dockerfile in the backend folder, but the creation of the dev environment failed.

Hello @rimelek !

Thank you for your answer ! Yes I had a backend folder to. I made a mistake when writing this question. Yet as you said even with the exemple from the docker documentation, I still can’t get any custom dev to run. It defaults to the generic one. Thank you for the answer still ! Very kind of you.

Have a good day.