1

I'm using Okteto CLI version 2.2.1, MacOS Monterey (Macbook 2015). I've cloned and deployed their playground app and created the following Okteto configuration:

name: movies-with-compose

# The build section defines how to build the images of your development environment
# More info: https://www.okteto.com/docs/reference/manifest/#build
build:

  # You can use the following env vars to refer to this image in your deploy commands:
  #  - OKTETO_BUILD_API_REGISTRY: image registry
  #  - OKTETO_BUILD_API_REPOSITORY: image repo
  #  - OKTETO_BUILD_API_IMAGE: image name
  #  - OKTETO_BUILD_API_TAG: image tag
  api:
    context: api
    dockerfile: api/Dockerfile

  # You can use the following env vars to refer to this image in your deploy commands:
  #  - OKTETO_BUILD_FRONTEND_REGISTRY: image registry
  #  - OKTETO_BUILD_FRONTEND_REPOSITORY: image repo
  #  - OKTETO_BUILD_FRONTEND_IMAGE: image name
  #  - OKTETO_BUILD_FRONTEND_TAG: image tag
  frontend:
    context: frontend
    dockerfile: frontend/Dockerfile

  # You can use the following env vars to refer to this image in your deploy commands:
  #  - OKTETO_BUILD_INIT_REGISTRY: image registry
  #  - OKTETO_BUILD_INIT_REPOSITORY: image repo
  #  - OKTETO_BUILD_INIT_IMAGE: image name
  #  - OKTETO_BUILD_INIT_TAG: image tag
  init:
    context: api
    dockerfile: api/Dockerfile

  # You can use the following env vars to refer to this image in your deploy commands:
  #  - OKTETO_BUILD_MOVIES_REGISTRY: image registry
  #  - OKTETO_BUILD_MOVIES_REPOSITORY: image repo
  #  - OKTETO_BUILD_MOVIES_IMAGE: image name
  #  - OKTETO_BUILD_MOVIES_TAG: image tag
  movies:
    context: reverse-proxy
    dockerfile: reverse-proxy/Dockerfile

# The deploy section defines how to deploy your development environment
# More info: https://www.okteto.com/docs/reference/manifest/#deploy
deploy:
  compose:
    file: docker-compose.yml

# The dependencies section defines other git repositories to be deployed as part of your development environment
# More info: https://www.okteto.com/docs/reference/manifest/#dependencies
# dependencies:
#   - https://github.com/okteto/sample


# The dev section defines how to activate a development container
# More info: https://www.okteto.com/docs/reference/manifest/#dev
dev:
  api:
    command:
      - yarn
      - start
    sync:
      - api:/usr/src/app
    environment:
      - MONGODB_DATABASE=okteto
      - MONGODB_HOST=mongodb
      - MONGODB_PASSWORD=mongodb123
      - MONGODB_USERNAME=okteto
    forward:
      - 8081:8080
  frontend:
    image: okteto/node:14
    command: bash
    workdir: /src
    sync:
      - frontend:/src
    forward:
      - 9229:9229
      - 8080:80
  movies:
    command: bash
    workdir: /usr/src/app
    sync:
      - .:/usr/src/app
    forward:
      - 9229:9229
      - 8080:80

I'm deploying the api container and no matter what file changes I perform to server.js they're not reflected in the deployment. I ran okteto status --info to get the remote Syncthing URL and it does display that server.js was changed when I click Recent Changes:

enter image description here

I started okteto by running okteto up and this is the output I get:

enter image description here

I can't figure out why changes to files which I make on my local machine are not reflected in okteto deployment (they're only reflected if I run okteto build and then re-deploy). Perhaps I misunderstood Okteto docs but I expected for file changes to be reflected instantly in okteto deployment.

The dockerfile for the service I'm starting in Okteto is:

FROM node:14

WORKDIR /src

COPY package.json yarn.lock ./
RUN yarn install

COPY . .

EXPOSE 8080

CMD ["yarn", "start"]

EDIT: the issue shouldn't occur anymore as a pull request fixing the issue was merged

Yos
  • 1,276
  • 1
  • 20
  • 40
  • Could you also include the content of your Dockerfile? (for api, since that's the one that's giving you problems) – Ramiro Berrelleza May 06 '22 at 01:21
  • @RamiroBerrelleza I updated the OP. Just wanted to say again that all of the source code is identical to this Okteto [repo](https://github.com/okteto/movies-with-compose) – Yos May 06 '22 at 07:32

1 Answers1

1

The issue was that the volume in docker-compose.yml for the api service is:

    volumes:
      - api:/usr/src/app

which is incorrect because the nodejs app is located in /src folder. Then when running okteto init the okteto manifest will automatically set the sync folder to api:/usr/src/app so any file changes locally will not result in updates in okteto cluster. Setting the volume in docker-compose.yml to be:

volumes:
      - api:/src

will solve the issue. In general I'm not sure volume should be defined at all in docker-compose.yml, I think it's enough to just define sync folder in okteto.yml (at least it worked for me because I guess Syncthing syncs files regardless of docker volume).

Yos
  • 1,276
  • 1
  • 20
  • 40
  • Yes, that does look like a bug on 'okteto init'. You are right that the volume should be 'api:/src'. `okteto.yml` can be used to override the sync folder of the docker-compose when running 'okteto up', which is why it worked for you. – Ramiro Berrelleza May 12 '22 at 17:03