-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
183 lines (160 loc) · 7.24 KB
/
Dockerfile
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
FROM debian:jessie
MAINTAINER Kabir Khaleque <[email protected]>
ARG VERSION
ENV VERSION ${VERSION:-v1.0}
# Add CouchDB user account
RUN groupadd -r couchdb && useradd -d /opt/couchdb -g couchdb couchdb
RUN apt-get update -y && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
erlang-nox \
erlang-reltool \
haproxy \
libicu52 \
libmozjs185-1.0 \
openssl \
vim \
less \
&& rm -rf /var/lib/apt/lists/*
# Add MySQL
RUN groupadd -r mysql && useradd -r -g mysql mysql
# grab gosu for easy step-down from root and tini for signal handling
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& curl -o /usr/local/bin/gosu -fSL "https://github.com/tianon/gosu/releases/download/1.7/gosu-$(dpkg --print-architecture)" \
&& curl -o /usr/local/bin/gosu.asc -fSL "https://github.com/tianon/gosu/releases/download/1.7/gosu-$(dpkg --print-architecture).asc" \
&& gpg --verify /usr/local/bin/gosu.asc \
&& rm /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 6380DC428747F6C393FEACA59A84159D7001A4E5 \
&& curl -o /usr/local/bin/tini -fSL "https://github.com/krallin/tini/releases/download/v0.14.0/tini" \
&& curl -o /usr/local/bin/tini.asc -fSL "https://github.com/krallin/tini/releases/download/v0.14.0/tini.asc" \
&& gpg --verify /usr/local/bin/tini.asc \
&& rm /usr/local/bin/tini.asc \
&& chmod +x /usr/local/bin/tini
RUN apt-get update && apt-get install -y --no-install-recommends \
# for MYSQL_RANDOM_ROOT_PASSWORD
pwgen \
# for mysql_ssl_rsa_setup
openssl \
# FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
# File::Basename
# File::Copy
# Sys::Hostname
# Data::Dumper
perl \
&& rm -rf /var/lib/apt/lists/*
RUN set -ex; \
# gpg: key 5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported
key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \
export GNUPGHOME="$(mktemp -d)"; \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
gpg --export "$key" > /etc/apt/trusted.gpg.d/mysql.gpg; \
rm -r "$GNUPGHOME"; \
apt-key list > /dev/null
ENV MYSQL_MAJOR 5.7
ENV MYSQL_VERSION 5.7.19-1debian8
RUN echo "deb http://repo.mysql.com/apt/debian/ jessie mysql-${MYSQL_MAJOR}" > /etc/apt/sources.list.d/mysql.list
# the "/var/lib/mysql" stuff here is because the mysql-server postinst doesn't have an explicit way to disable the mysql_install_db codepath besides having a database already "configured" (ie, stuff in /var/lib/mysql/mysql)
# also, we set debconf keys to make APT a little quieter
RUN { \
echo mysql-community-server mysql-community-server/data-dir select ''; \
echo mysql-community-server mysql-community-server/root-pass password ''; \
echo mysql-community-server mysql-community-server/re-root-pass password ''; \
echo mysql-community-server mysql-community-server/remove-test-db select false; \
} | debconf-set-selections \
&& apt-get update && apt-get install -y mysql-server="${MYSQL_VERSION}" && rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/run/mysqld /var/lib/mysql/log \
&& chown -R mysql:mysql /var/lib/mysql /var/run/mysqld \
# ensure that /var/run/mysqld (used for socket and lock files) is writable regardless of the UID our mysqld instance ends up having at runtime
&& chmod 777 /var/run/mysqld
# grab gosu for easy step-down from root and tini for signal handling
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& curl -o /usr/local/bin/gosu -fSL "https://github.com/tianon/gosu/releases/download/1.7/gosu-$(dpkg --print-architecture)" \
&& curl -o /usr/local/bin/gosu.asc -fSL "https://github.com/tianon/gosu/releases/download/1.7/gosu-$(dpkg --print-architecture).asc" \
&& gpg --verify /usr/local/bin/gosu.asc \
&& rm /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 6380DC428747F6C393FEACA59A84159D7001A4E5 \
&& curl -o /usr/local/bin/tini -fSL "https://github.com/krallin/tini/releases/download/v0.14.0/tini" \
&& curl -o /usr/local/bin/tini.asc -fSL "https://github.com/krallin/tini/releases/download/v0.14.0/tini.asc" \
&& gpg --verify /usr/local/bin/tini.asc \
&& rm /usr/local/bin/tini.asc \
&& chmod +x /usr/local/bin/tini
# https://www.apache.org/dist/couchdb/KEYS
ENV GPG_KEYS \
15DD4F3B8AACA54740EB78C7B7B7C53943ECCEE1 \
1CFBFA43C19B6DF4A0CA3934669C02FFDF3CEBA3 \
25BBBAC113C1BFD5AA594A4C9F96B92930380381 \
4BFCA2B99BADC6F9F105BEC9C5E32E2D6B065BFB \
5D680346FAA3E51B29DBCB681015F68F9DA248BC \
7BCCEB868313DDA925DF1805ECA5BCB7BB9656B0 \
C3F4DFAEAD621E1C94523AEEC376457E61D50B88 \
D2B17F9DA23C0A10991AF2E3D9EE01E47852AEE4 \
E0AF0A194D55C84E4A19A801CDB0C0F904F4EE9B \
29E4F38113DF707D722A6EF91FE9AF73118F1A7C \
2EC788AE3F239FA13E82D215CDE711289384AE37
RUN set -xe \
&& for key in $GPG_KEYS; do \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
done
ENV COUCHDB_VERSION 2.1.0
# Download dev dependencies
RUN buildDeps=' \
apt-transport-https \
gcc \
g++ \
erlang-dev \
libcurl4-openssl-dev \
libicu-dev \
libmozjs185-dev \
make \
' \
&& apt-get update -y -qq && apt-get install -y --no-install-recommends $buildDeps \
# Acquire CouchDB source code
&& cd /usr/src && mkdir couchdb \
&& curl -fSL https://dist.apache.org/repos/dist/release/couchdb/source/$COUCHDB_VERSION/apache-couchdb-$COUCHDB_VERSION.tar.gz -o couchdb.tar.gz \
&& curl -fSL https://dist.apache.org/repos/dist/release/couchdb/source/$COUCHDB_VERSION/apache-couchdb-$COUCHDB_VERSION.tar.gz.asc -o couchdb.tar.gz.asc \
&& gpg --verify couchdb.tar.gz.asc \
&& tar -xzf couchdb.tar.gz -C couchdb --strip-components=1 \
&& cd couchdb \
# Build the release and install into /opt
&& ./configure --disable-docs \
&& make release \
&& mv /usr/src/couchdb/rel/couchdb /opt/ \
# Cleanup build detritus
&& apt-get purge -y --auto-remove $buildDeps \
&& rm -rf /var/lib/apt/lists/* /usr/src/couchdb*
RUN curl -svL https://deb.nodesource.com/setup_8.x | bash - \
&& apt-get install -y nodejs
# Add configuration
COPY local.ini /opt/couchdb/etc/local.d/
COPY vm.args /opt/couchdb/etc/
# COPY couchdbreverseproxy/go/couchdbreverseproxy /
# COPY www/public /www/public
COPY server.crt /
COPY server.key /
COPY ./docker-entrypoint.sh /
COPY ./post.sh /
COPY ./remove_all_assets.sh /
RUN mkdir /restful /shared /events /configuration
COPY couchdbreverseproxy/nodejs/*.js /
COPY couchdbreverseproxy/nodejs/restful/*.js /restful/
COPY couchdbreverseproxy/nodejs/shared/* /shared/
COPY couchdbreverseproxy/nodejs/events/*.js /events/
COPY couchdbreverseproxy/nodejs/configuration/* /configuration/
# Setup directories and permissions
RUN chmod +x /*.sh *.js \
&& mkdir /opt/couchdb/data \
&& chown -R couchdb:couchdb /opt/couchdb/ \
&& chown couchdb:couchdb /*.sh \
&& chown couchdb:couchdb /server.crt \
&& chown couchdb:couchdb /server.key
COPY my.cnf /var/lib/mysql
COPY init.sql /
COPY mysqld.sh /
WORKDIR /opt/couchdb
EXPOSE 8443 5986 6984 4369 9100 3306
VOLUME ["/opt/couchdb/data"]
RUN /mysqld.sh --init
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
CMD ["/opt/couchdb/bin/couchdb"]