cannot deploy a pypiserver as a service on my docker swarm cluster

17 Views Asked by At

ello. I'm trying to deploy a PyPiServer service within my Docker Swarm stack. Unfortunately, I'm unable to deploy the PyPiServer service. Here's my stack, and I want to specify that I've created the pypi.yaml file in my current directory. I've also created my .htpasswd file in my current directory and the packages folder in my current directory. And it's from my current directory that I want to launch the stack. So, if there are any errors in my pypi.yaml configuration, please, your help would be appreciated.

version: '3.8'

services:
  pypi-server:
    image: pypiserver/pypiserver:latest
    networks:
      - traefik-public
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.pypi-server.rule=Host(`pypi.mydomaine.com`)"
        - "traefik.http.services.pypi-server.loadbalancer.server.port=8080"
        - "traefik.http.routers.pypi-server.entrypoints=websecure"
        - "traefik.http.routers.pypi-server.tls=true"
        - "traefik.http.routers.pypi-server.tls.certresolver=leresolver"
    ports:
      - "8081:8080"
    volumes:
      - /home/sheguey/.htpasswd:/data/auth/.htpasswd
      - /home/sheguey/packages:/data/packages
    command: -P /data/auth/.htpasswd -a update,download,list /data/packages
    restart: always

networks:
  traefik-public:
    external: true

i just wanna deploy my pypi server in my docker swarm cluster

1

There are 1 best solutions below

0
Chris Becke On

While Docker Swarm does work in a single node configuration, to support multi node configurations you need to take advantage of docker configs, as well as some kind of distributed or network file storage to ensure that each node can reach the required config and data files.

I have modified the provided file to show how a docker config can be created from a .htpasswd file in the same folder as the stack.yaml file, and mounted into target containers - and how a volume can be defined that mounts a network share.


configs:
  htpasswd:
    file: .htpasswd

volumes:
  packages:
    driver_opts:
      type: "nfs"
      o: "nolock,soft,rw"
      device: "nfs-server-ip:/packages"

services:
  server:
    image: pypiserver/pypiserver:latest
    networks:
      - traefik
    deploy:
      labels:
        traefik.enable: "true"
        traefik.http.routers.pypi-server.rule: HostRegexp(`pypi.{any:.*}`)
        traefik.http.services.pypi-server.loadbalancer.server.port: 8080
        traefik.http.routers.pypi-server.entrypoints: websecure
        traefik.http.routers.pypi-server.tls: "true"
        traefik.http.routers.pypi-server.tls.certresolver: leresolver
    volumes:
      - packages:/data/packages
    configs:
      - source: htpasswd
        target: /data/auth/.htpasswd
    command: -P /data/auth/.htpasswd -a update,download,list /data/packages

networks:
  traefik:
    external: true
    name: traefik-public