0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

svnサーバをdockerで立てる

0
Posted at

svnサーバ を docker-compose で起こしてみました

Appache(WebDAV)経由でアクセスすることにして、BASIC認証をセットしています

Dockerfile

FROM ubuntu:20.04

# インタラクティブな入力を無効化(これがないとビルドが止まる)
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Tokyo

# 必要なパッケージのインストール
RUN apt-get update && apt-get install -y \
    apache2 \
    subversion \
    libapache2-mod-svn \
    apache2-utils \
    tzdata \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf

RUN mkdir -p /var/svn && chown -R www-data:www-data /var/svn

# Apache の設定
RUN rm -f /etc/apache2/sites-available/000-default.conf \
    && printf '<VirtualHost *:80>\n\
    DocumentRoot /var/www/html\n\
    <Location /svn>\n\
        DAV svn\n\
        SVNParentPath /var/svn\n\
        AuthType Basic\n\
        AuthName "Subversion Repository"\n\
        AuthUserFile /etc/apache2/.htpasswd\n\
        Require valid-user\n\
    </Location>\n\
    ErrorLog ${APACHE_LOG_DIR}/error.log\n\
    CustomLog ${APACHE_LOG_DIR}/access.log combined\n\
</VirtualHost>\n' > /etc/apache2/sites-available/svn-site.conf

RUN a2dissite 000-default.conf \
    && a2ensite svn-site.conf \
    && a2enmod dav dav_fs dav_svn


# 起動コマンド
CMD ["apachectl", "-D", "FOREGROUND"]

docker-compose.yml

ポート61009で作っています

services:
  svn:
    build: .
    container_name: svn
    ports:
      - "61009:80"
    volumes:
      - ./.docker/repos:/var/svn
      - ./.docker/config/.htpasswd:/etc/apache2/.htpasswd
    restart: always

あらかじめ「.htpasswd」を作っておく

touch svn/.docker/config/.htpasswd

実行

「--build」付きで起こす

docker compose up -d --build

BASIC認証ユーザ(パスワード)作成

sudo docker exec -it svn htpasswd /etc/apache2/.htpasswd user1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?