-
Notifications
You must be signed in to change notification settings - Fork 39
/
Dockerfile-dev
120 lines (90 loc) · 4.16 KB
/
Dockerfile-dev
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
FROM ubuntu:16.04
MAINTAINER Nicola <[email protected]>, \
BazZy <[email protected]>, \
Danil Kutkevich <[email protected]>
ENV REFRESHED_AT 20160425T0900Z
RUN localedef --force --inputfile=en_US --charmap=UTF-8 \
--alias-file=/usr/share/locale/locale.alias \
en_US.UTF-8
ENV LANG en_US.UTF-8
RUN apt-get --yes update
RUN apt-get --yes upgrade
# Add PostgreSQL (9.1, 9.2, 9.3, 9.4, 9.5) apt repository
# <http://www.postgresql.org/download/linux/ubuntu/>.
RUN apt-get install --yes curl sudo
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main' \
> /etc/apt/sources.list.d/pgdg.list
RUN curl --silent https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -
RUN apt-get --yes update
RUN apt-get --yes upgrade
# Install PostgreSQL.
ENV PG_MAJOR 9.4
RUN apt-get install --yes postgresql-$PG_MAJOR
# Install plv8 (in case of plv8 compilation issues address to
# README in <https://github.com/clkao/docker-postgres-plv8>).
RUN apt-get install --yes git build-essential libv8-dev postgresql-server-dev-$PG_MAJOR
RUN apt-get install --yes nodejs-dev
# Adjust PostgreSQL configuration so that remote connections to the
# database are possible.
RUN echo 'host all all 0.0.0.0/0 md5' >> /etc/postgresql/$PG_MAJOR/main/pg_hba.conf
RUN echo 'local all all trust' >> /etc/postgresql/$PG_MAJOR/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/$PG_MAJOR/main/postgresql.conf
USER postgres
# Fix PostgreSQL locale
# <http://stackoverflow.com/questions/16736891/pgerror-error-new-encoding-utf8-is-incompatible#16737776>,
# <http://www.postgresql.org/message-id/[email protected]>,
# <http://www.postgresql.org/docs/current/static/multibyte.html#AEN35730>.
RUN service postgresql start \
&& psql --command="UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';" \
&& psql --command="DROP DATABASE template1;" \
&& psql --command="CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8';" \
&& psql --command="UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';" \
&& psql --command="CREATE ROLE fhirbase WITH SUPERUSER LOGIN PASSWORD 'fhirbase';" \
&& psql --command="CREATE DATABASE fhirbase WITH OWNER fhirbase ENCODING = 'UTF8';"
USER root
RUN useradd --user-group --create-home --shell /bin/bash fhirbase \
&& echo 'fhirbase:fhirbase' | chpasswd && adduser fhirbase sudo
RUN echo 'fhirbase ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
USER fhirbase
RUN cd ~ \
&& git clone https://github.com/fhirbase/fhirbase-plv8.git fhirbase \
&& cd ~/fhirbase \
&& git submodule update --init --recursive
# Install nodejs.
RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh \
| bash
RUN bash -lc 'source ~/.nvm/nvm.sh && nvm install 6.2.0'
RUN bash -lc 'cd ~/fhirbase && source ~/.nvm/nvm.sh && nvm use 6.2.0 \
&& npm install'
RUN bash -lc 'cd ~/fhirbase/plpl && source ~/.nvm/nvm.sh && nvm use 6.2.0 \
&& npm install'
USER root
ENV PLV8_VERSION v1.4.7
RUN cd /tmp \
&& git clone https://github.com/plv8/plv8.git \
&& cd /tmp/plv8 \
&& git checkout $PLV8_VERSION \
&& make all install
USER fhirbase
# Install fhirbase.
RUN bash -lc 'sudo service postgresql start \
&& cd ~/fhirbase \
&& source ~/.nvm/nvm.sh && nvm use 6.2.0 \
&& export PATH="$HOME"/fhirbase/node_modules/coffee-script/bin:"$PATH" \
&& export DATABASE_URL=postgres://fhirbase:fhirbase@localhost:5432/fhirbase \
&& ~/fhirbase/build-commit.sh --rebuild \
&& cat ~/fhirbase/build/latest/build.sql | psql fhirbase'
USER root
COPY docker-run-tests.sh /
RUN chmod a+rwx /docker-run-tests.sh
RUN chown fhirbase /docker-run-tests.sh
# Install utils.
RUN apt-get install --yes openssh-server aptitude
USER fhirbase
# Expose the PostgreSQL port.
EXPOSE 5432
# Add VOLUMEs to allow backup of config, logs, socket and databases
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql", "/var/run/postgresql"]
WORKDIR /home/fhirbase
CMD /bin/bash