---
version: "2.1"
services:
  code-server:
    image: lscr.io/linuxserver/code-server:latest
    container_name: code-server
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - PASSWORD=password #optional
      - HASHED_PASSWORD= #optional
      - SUDO_PASSWORD=password #optional
      - SUDO_PASSWORD_HASH= #optional
      - PROXY_DOMAIN=code-server.jimsgarage.co.uk #optional
      - DEFAULT_WORKSPACE=/config/workspace #optional
    volumes:
      - /home/ubuntu/docker/code-server/config:/config
    networks:
      proxy:
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.code-server.entrypoints=http"
      - "traefik.http.routers.code-server.rule=Host(`code-server.yourdomain.com`)"
      - "traefik.http.middlewares.code-server-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.code-server.middlewares=code-server-https-redirect"
      - "traefik.http.routers.code-server-secure.entrypoints=https"
      - "traefik.http.routers.code-server-secure.rule=Host(`code-server.yourdomain.com`)"
      - "traefik.http.routers.code-server-secure.tls=true"
      - "traefik.http.routers.code-server-secure.service=code-server"
      - "traefik.http.services.code-server.loadbalancer.server.port=8443"
      - "traefik.docker.network=proxy"
    restart: unless-stopped

networks:
  proxy:
    external: true
