Git Product home page Git Product logo

docker-yumrepo's Introduction

Docker Yum Repository

This is a tiny container based on Alpine distro that acts as a 'yum' repository to test your RPMs.



Docker Image


Requirements

  • docker-engine >= 1.12
  • docker-compose >= 1.8.1

Limitations

  • Does not (yet) work with repositories containing comps.xml

How-to

Manually (with docker run)

You can manually run these commands:

docker run -d -v <path_to_rpms>:/var/repo:rw robomagus/yum-repo

You must mount a directory inside of the container the contains all RPM's that you want serve. This directory may have other nested directories to respect the structure of a Yum repository; for example 6/x86_64, 6/i386, 7/x86_64.

Run via docker-compose

There is a docker-compose.yml file to enable launching via docker compose. To use this you will need a local checkout of this repo and have docker and compose installed.

Run the following command in the same directory as the docker-compose.yml file:

 docker-compose up

You can customize the docker-compose.yml:

version: '2'

services:
  yumrepo:
    image: robomagus/yum-repo
    hostname: yumrepo
    container_name: yumrepo
    ports:
      - 80
    volumes:
      - ./extras/dummyrepo:/var/repo:rw
      - /etc/localtime:/etc/localtime
    environment:
      - REPO_PORT=80
      - REPO_PATH=/var/repo
      - REPO_DEPTH=2
      - USE_UPDATE=1
      - FIND_SYMLINKS=0

  centos6:
    image: centos:6
    hostname: centos6-client
    container_name: centos6-client
    links:
      - yumrepo:repo
    volumes:
      - ./extras/yum/container.repo:/etc/yum.repos.d/container.repo:ro
      - /etc/localtime:/etc/localtime
    command: yum --disablerepo=* --enablerepo=container install dummy-package-1.2

  centos7:
    image: centos:7
    hostname: centos7-client
    container_name: centos7-client
    links:
      - yumrepo:repo
    volumes:
      - ./extras/yum/container.repo:/etc/yum.repos.d/container.repo:ro
      - /etc/localtime:/etc/localtime
    command: yum --disablerepo=* --enablerepo=container info dummy-package-1.0_SNAPSHOT

Tuning

The docker image can be tuned using environment variables.

REPO_PORT

Repository listening port. Use the -e REPO_PORT=80 to set the listening port.

REPO_PATH

Base path where the repository will be created inside the container. Use the -e REPO_PATH=/var/repo.

REPO_DEPTH

Number of levels that will have the repository to create. For example, use -e REPO_DEPTH=2 if your repository have two levels depth (/).

HTTPS support
REPO_PROTO

If set to https the repository will be exposed over HTTPS rather than the default HTTP.

REPO_CERT

Path to SSL certificate file.

REPO_KEY

Path to SSL key file.

USE_UPDATE

If set to 1, the createrepo command is run with the --update argument to speed-up the process for larger repositories.

FIND_SYMLINKS

If set to 1, the find command used to determine where repodata should be created will follow symlinks (Disabled by default) Note that this does not listen for changes behind the symlink!!

Example

Fragment of docker-compose.yml:

services:
  yumrepo:
    image: robomagus/yum-repo
    hostname: yumrepo
    container_name: yumrepo
    ports:
      - 443
    volumes:
      - ./extras/dummyrepo:/var/repo:rw
      - /etc/localtime:/etc/localtime
      - ./certs:/certs
    environment:
      - REPO_PORT=443
      - REPO_PROTO=https
      - REPO_CERT=/certs/repo.crt
      - REPO_KEY=/certs/repo.key
      - REPO_PATH=/var/repo
      - REPO_DEPTH=2
      - USE_UPDATE=1
      - FIND_SYMLINKS=0
      
  ...

GPG Repository Signing

Use with care: automatically signs repository without requiring the repository updater to provide a GPG passphrase.

As a first step, the GPG secret key must be exported to a file which must then be mounted as volume /var/repo.key - ie. gpg --export-secret-keys repo-key-name > repo.key.

REPO_GPG_KEY_NAME

Name of GPG key (repo-key-name in above example).

REPO_GPG_PASSPHRASE

Passphrase for GPG key.

Rather than hard-coding this in docker-compose.yml, consider providing from the host environment or using an environment file.

Example

Fragment of docker-compose.yml:

services:
  yumrepo:
    image: intraway/yum-repo
    hostname: yumrepo
    container_name: yumrepo
    ports:
      - 443
    volumes:
      - ./extras/dummyrepo:/var/repo:rw
      - ./repo.key:/var/repo.key:ro
      - /etc/localtime:/etc/localtime
    environment:
      - REPO_GPG_KEY_NAME=Repo Signing Key
      - REPO_GPG_PASSPHRASE      
      - REPO_PATH=/var/repo
      - REPO_DEPTH=2
      - USE_UPDATE=1
      - FIND_SYMLINKS=0
  ...

To-Do

  • Listening for improvements

hacker emblem

docker-yumrepo's People

Contributors

stevejefferson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.