Skip to content

Commit 5979dd5

Browse files
authored
Switch to alpine image (rbkmoney#4)
* Switch to alpine image * Fix entrypoint
1 parent 53e611d commit 5979dd5

File tree

2 files changed

+28
-46
lines changed

2 files changed

+28
-46
lines changed

Dockerfile

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,40 @@
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
82

93
MAINTAINER Pavel Popov <p.popov@rbkmoney.com>
104

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/*
1210

11+
COPY data /opt/binbase-test-data/data
12+
RUN unzip /opt/binbase-test-data/data/\*.zip -d /opt/binbase-test-data/data/unzip
1313

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
2123

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
2725

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
3326
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/* \
4732
&& chmod +x /opt/binbase-test-data/entrypoint.sh
4833

4934
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/
5638

5739
WORKDIR /opt/binbase-test-data
5840
ENTRYPOINT ["/opt/binbase-test-data/entrypoint.sh"]

entrypoint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22
function onExit {
3-
pg_ctl -D /var/lib/postgresql/9.6/data stop -w
3+
service postgresql stop
44
}
55
trap onExit EXIT
66

7-
pg_ctl -D /var/lib/postgresql/9.6/data start -w
7+
service postgresql start
88
$@
99
exit $?

0 commit comments

Comments
 (0)