aboutsummaryrefslogtreecommitdiff
path: root/bugzilla/Dockerfile
blob: 8ebf9118433811bbdc7d7fa530a38dab18a8f40c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
FROM ubuntu:16.04
MAINTAINER Michael Crute <mike@crute.us>
ARG bz_version

ADD binaries/ /tmp/
ADD patches/ /tmp/

RUN export DEBIAN_FRONTEND=noninteractive && \
    echo 'Acquire::http::Proxy "http://genesis.sea1.crute.me:3142";' > /etc/apt/apt.conf && \
    apt-get update && \

# Perl needs the UTF-8 locale
    apt-get install -y locales && \
    locale-gen en_US.UTF-8 && \

# Install system dependencies
    apt-get install -y \
        cron \
        nginx \
        patch \
        python-boto3 \
        runit \
        sudo \
        syslog-ng \
    && \

# Install Bugzilla dependencies
    apt-get install -y \
        graphviz \
        libappconfig-perl \
        libauthen-radius-perl \
        libauthen-sasl-perl \
        libcache-memcached-fast-perl \
        libcgi-pm-perl \
        libchart-perl \
        libdaemon-generic-perl \
        libdate-calc-perl \
        libdatetime-perl \
        libdatetime-timezone-perl \
        libdbd-mysql-perl \
        libdbd-sqlite3-perl \
        libdbi-perl \
        libemail-mime-perl \
        libemail-reply-perl \
        libemail-sender-perl \
        libencode-detect-perl \
        libfile-copy-recursive-perl \
        libfile-mimeinfo-perl \
        libfile-slurp-perl \
        libfile-which-perl \
        libgd-graph-perl \
        libhtml-formattext-withlinks-perl \
        libhtml-scrubber-perl \
        libjson-rpc-perl \
        libmath-random-isaac-perl \
        libmath-random-isaac-xs-perl \
        libmime-tools-perl \
        libmodule-build-perl \
        libmoox-strictconstructor-perl \
        libnet-ldap-perl \
        libplack-perl \
        libsoap-lite-perl \
        libtemplate-perl \
        libtemplate-plugin-gd-perl \
        libtest-taint-perl \
        libtext-multimarkdown-perl \
        libtheschwartz-perl \
        liburi-db-perl \
        libxml-perl \
        libxml-twig-perl \
        perlmagick \
        python-sphinx \
        rst2pdf \
    && \

    dpkg -i /tmp/libpatchreader-perl_0.9.6-1_all.deb && \
    dpkg -i /tmp/libtheschwartz-perl_1.12-1_all.deb && \

# Setup users and groups
    groupadd -g 901 bugzilla && \
    usermod -a -G bugzilla www-data && \
    useradd -d /var/www/html/bugzilla -M -N -g bugzilla -G www-data -s /bin/bash -u 901 bugzilla && \

# Setup bugzilla app
    curl -L -o "/tmp/release-${bz_version}.tar.gz" "https://github.com/bugzilla/bugzilla/archive/release-${bz_version}.tar.gz" && \
    mkdir -p /var/www/html && \
    tar -C /var/www/html/ -xvzf /tmp/release-${bz_version}.tar.gz && \
    ln -s /var/www/html/bugzilla-release-${bz_version} /var/www/html/bugzilla && \
    tar -C /var/www/html/bugzilla/skins/contrib/ -xvzf /tmp/Bright-Skin.tar.gz && \
    rm /etc/nginx/sites-enabled/default && \
    ln -s /etc/nginx/sites-available/bugzilla /etc/nginx/sites-enabled/bugzilla && \

# Run the initial setup
#
# The bugzilla user must have permissions to modify files in the release
# directory because checksetup.pl will change permissions so that the files are
# owned by that user. Without those permission changes running plack will fail
# with permission errors. Additionally, all checksetup.pl invocations must
# happen as the bugzilla user for permissions to be properly updated.

    chown -R bugzilla /var/www/html/bugzilla-release-${bz_version} && \

    # First time creates the config file
    cd /var/www/html/bugzilla && sudo -u bugzilla ./checksetup.pl /tmp/answers.pl && \

    # Second time does the real setup
    cd /var/www/html/bugzilla && sudo -u bugzilla ./checksetup.pl /tmp/answers.pl && \

# Allow admin overrides
    mkdir /srv/bugzilla && \

    mv /var/www/html/bugzilla/localconfig /srv/bugzilla/localconfig && \
    ln -s /srv/bugzilla/localconfig /var/www/html/bugzilla/localconfig && \

    mv /var/www/html/bugzilla/data/db /srv/bugzilla/ && \
    ln -s /srv/bugzilla/db /var/www/html/bugzilla/data/ && \

    mv /var/www/html/bugzilla/data/attachments /srv/bugzilla/ && \
    ln -s /srv/bugzilla/attachments /var/www/html/bugzilla/data/ && \

    mv /var/www/html/bugzilla/data/mining /srv/bugzilla/ && \
    ln -s /srv/bugzilla/mining /var/www/html/bugzilla/data/ && \

    cp /var/www/html/bugzilla/data/params.json /srv/bugzilla/ && \

# Enable voting extension
    rm /var/www/html/bugzilla/extensions/Voting/disabled && \

# Patch the code
    # Update the email_in script to lookup by email instead of assuming that
    # usernames are the same as email addresses.
    cd / && patch -p1 < /tmp/email_in.pl.patch && \

# Clean up
    rm /etc/apt/apt.conf && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* && \
    rm -rf /tmp/*

ADD usr/ /usr/
ADD etc/ /etc/

STOPSIGNAL SIGHUP
CMD [ "/usr/bin/dumb-init", "/usr/bin/runsvdir", "/etc/service" ]