|
1 | | -FROM alpine:latest as unzip-apk |
2 | | -RUN apk update && apk add unzip |
3 | | -COPY data /opt/binbase-test-data/data |
4 | | -RUN unzip /opt/binbase-test-data/data/\*.zip -d /opt/binbase-test-data/data/unzip |
5 | | - |
6 | | -FROM dr2.rbkmoney.com/rbkmoney/binbase:8faa3606076e044b62f141d2cb1060b719491618 as binbase-test-data |
7 | | -FROM dr2.rbkmoney.com/rbkmoney/build:f3732d29a5e622aabf80542b5138b3631a726adb as build |
| 1 | +FROM dr2.rbkmoney.com/rbkmoney/binbase:05910a0cf3634ad3d8826b7b70d3a8b70444c2f4 as build |
8 | 2 |
|
9 | 3 | MAINTAINER Pavel Popov <p.popov@rbkmoney.com> |
10 | 4 |
|
11 | | -COPY --from=binbase-test-data / /tmp/portage-root/ |
| 5 | +RUN apt update \ |
| 6 | + && apt install -y \ |
| 7 | + postgresql \ |
| 8 | + unzip \ |
| 9 | + && rm -rf /var/lib/apt/lists/* |
12 | 10 |
|
| 11 | +COPY data /opt/binbase-test-data/data |
| 12 | +RUN unzip /opt/binbase-test-data/data/\*.zip -d /opt/binbase-test-data/data/unzip |
13 | 13 |
|
14 | | -ENV PGDATA "/etc/postgresql-9.6/" |
15 | | -ENV DATA_DIR "/var/lib/postgresql/9.6/data" |
16 | | -ENV PG_INITDB_OPTS "--username=postgres --auth-host=trust --auth-local=trust --locale=en_US.UTF-8" |
17 | | - |
18 | | -ENV ROOT=/tmp/portage-root |
19 | | - |
20 | | -ENV LD_LIBRARY_PATH=$ROOT/usr/lib64/ |
| 14 | +USER postgres |
| 15 | +RUN service postgresql start \ |
| 16 | + && psql --command "CREATE DATABASE binbase;" \ |
| 17 | + && psql --command "ALTER USER postgres WITH SUPERUSER PASSWORD 'postgres';" \ |
| 18 | + && java -jar /opt/binbase/binbase.jar com.rbkmoney.binbase.config.BatchConfig binBaseJob --logging.level.com.rbkmoney.binbase=ERROR --logging.level.com.rbkmoney.binbase.batch.listener.DefaultChunkListener=INFO --batch.file_path=file:/opt/binbase-test-data/data/unzip --batch.shutdown_after_execute=true \ |
| 19 | + && psql --command "SELECT pg_size_pretty(pg_database_size('binbase'));" \ |
| 20 | + && psql --command "VACUUM FULL;" \ |
| 21 | + && psql --command "SELECT pg_size_pretty(pg_database_size('binbase'));" \ |
| 22 | + && service postgresql stop |
21 | 23 |
|
22 | | -RUN mkdir -p /etc/postgresql-9.6/ && echo dev-db/postgresql server > /etc/portage/package.use/postgresql \ |
23 | | - && git clone git://git.bakka.su/gentoo-mirror --depth 1 /usr/portage \ |
24 | | - && /sbin/ldconfig /$ROOT/usr/lib64/ \ |
25 | | - && emerge --usepkgonly --binpkg-respect-use dev-db/postgresql:9.6 \ |
26 | | - && emerge --config dev-db/postgresql:9.6 |
| 24 | +FROM dr2.rbkmoney.com/rbkmoney/binbase:05910a0cf3634ad3d8826b7b70d3a8b70444c2f4 |
27 | 25 |
|
28 | | -FROM dr2.rbkmoney.com/rbkmoney/binbase:8faa3606076e044b62f141d2cb1060b719491618 |
29 | | -ENV LOG_PATH /tmp/ |
30 | | -COPY --from=build /tmp/portage-root/ / |
31 | | -COPY --from=build /var/lib/postgresql/9.6/data /var/lib/postgresql/9.6/data |
32 | | -COPY --from=build /etc/postgresql-9.6 /etc/postgresql-9.6 |
33 | 26 | COPY entrypoint.sh /opt/binbase-test-data/entrypoint.sh |
34 | | -COPY --from=unzip-apk /opt/binbase-test-data/data/unzip /opt/binbase-test-data/data |
35 | | - |
36 | | -RUN echo postgres:x:70: >> /etc/group \ |
37 | | - && echo postgres:x:70:70::/var/lib/postgresql:/bin/sh >> /etc/passwd \ |
38 | | - && echo postgres:!:17725:::::: >> /etc/shadow \ |
39 | | - && mkdir /run /run/postgresql |
40 | | - |
41 | | -RUN chmod 0700 -R /var/lib/postgresql/9.6/data \ |
42 | | - && chown postgres:postgres -R \ |
43 | | - /var/lib/postgresql/9.6/data \ |
44 | | - /etc/postgresql-9.6\ |
45 | | - /run/postgresql \ |
46 | | - /opt/binbase-test-data \ |
| 27 | + |
| 28 | +RUN apt update \ |
| 29 | + && apt install -y \ |
| 30 | + postgresql \ |
| 31 | + && rm -rf /var/lib/apt/lists/* \ |
47 | 32 | && chmod +x /opt/binbase-test-data/entrypoint.sh |
48 | 33 |
|
49 | 34 | USER postgres |
50 | | -RUN pg_ctl -D /var/lib/postgresql/9.6/data start -w \ |
51 | | - && psql --command "ALTER USER postgres WITH SUPERUSER PASSWORD 'postgres';" \ |
52 | | - && createdb -O postgres binbase \ |
53 | | - && java -jar /opt/binbase/binbase.jar com.rbkmoney.binbase.config.BatchConfig binBaseJob --logging.level.com.rbkmoney.binbase=ERROR --logging.level.com.rbkmoney.binbase.batch.listener.DefaultChunkListener=INFO --batch.file_path=file:/opt/binbase-test-data/data --batch.shutdown_after_execute=true \ |
54 | | - && pg_ctl -D /var/lib/postgresql/9.6/data stop -w \ |
55 | | - && rm -rf /opt/binbase-test-data/data/* |
| 35 | + |
| 36 | +COPY --chown=postgres:postgres --from=build /var/lib/postgresql/ /var/lib/postgresql/ |
| 37 | +COPY --chown=postgres:postgres --from=build /etc/postgresql/ /etc/postgresql/ |
56 | 38 |
|
57 | 39 | WORKDIR /opt/binbase-test-data |
58 | 40 | ENTRYPOINT ["/opt/binbase-test-data/entrypoint.sh"] |
|
0 commit comments