Skip to content

Add content for dockerfile #51

@MichaelCurrin

Description

@MichaelCurrin
## Fields

Setting fields like `dockerfile`, `command`, `volume` and `environment`.

```yaml
services:
  mya_app:
    build:
      context: ..
      dockerfile: .devcontainer/Dockerfile
    command: sleep infinity
    volumes:
      - ..:/workspace
    environment:
      - DEBUG=0
      - ENVIRONMENT=local
    ports:
      - "8000:8000"
      - "8081:8081"
    depends_on:
      - my_app_db
```

For external services, it can be shorter:

```yaml
services:
  my_app_db:
    image: postgres:14
    volumes:
      - my_app_db_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U commodities" ]
      interval: 5s
      timeout: 5s
      retries: 5

  redis:
    image: redis:alpine
    ports:
      - "6379:6379"

  nginx:
    container_name: nginx
    image: nginx:1.18
    ports:
      - "80:80"
    volumes:
      - "./nginx.conf:/etc/nginx/conf.d/default.conf"
```

You can set credentials in `environment` for a DB but it could be better to use unversioned secrets file instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions