Skip to content

Commit 28709dd

Browse files
committed
Create docker image for release
1 parent f4db452 commit 28709dd

File tree

4 files changed

+66
-8
lines changed

4 files changed

+66
-8
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ ops_start:
2727

2828
dev_ui:
2929
cd priv/ui && ${shell command -v rlwrap} lein figwheel
30+
31+
app_image:
32+
docker build -f docker/Dockerfile -t holiday-ping .

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,20 @@ Which uses figwheel to provide a REPL and hot-reload of the code changes.
4040

4141
## Production install
4242

43-
Inside the devops folder you can find an install shell script for installing holiday_ping in a debian 9 serer.
43+
Inside the devops folder you can find an [install shell script](devops/sh/install.sh) for installing holiday_ping in a debian 9 server. On the other hand, you can do `make app_image` to generate a Docker image of HolidayPing called `holiday-ping`.
44+
45+
The release generated for `prod` expects some config values from the environment. If you prefer, you can modify [prod.config](conf/prod.config) to directly set the values and re-make the release or image. The expected environment variables are this:
46+
47+
- `RELX_REPLACE_OS_VARS=true`
48+
- `SSL_CERTFILE=</dir/of/ssl/fullchain.pem>`
49+
- `SSL_KEYFILE=</dir/of/ssl/privkey.pem>`
50+
- `TOKEN_SECRET=<secret_token_hash>`
51+
- `POSTGRES_HOST=<holiday_ping_postgres_1>`
52+
- `POSTGRES_USER=<postgres user>`
53+
- `POSTGRES_PASSWORD=<postgres user password>`
54+
- `POSTGRES_DB=<postgres database>`
55+
56+
**NOTE:** Remember to mount the folder where `SSL_CERTFILE` and `SSL_KEYFILE` are stored into the container.
4457

4558
### Credentials
4659
#### GitHub login configuration

conf/prod.config

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22
{holiday_ping, [
33
{protocol, https},
44
{port, 443},
5-
{certfile, "/etc/letsencrypt/live/holidayping.lambdaclass.com/fullchain.pem"},
6-
{keyfile, "/etc/letsencrypt/live/holidayping.lambdaclass.com/privkey.pem"},
7-
{token_secret, <<"FIXME!!!">>},
5+
{certfile, "${SSL_CERTFILE}"},
6+
{keyfile, "${SSL_KEYFILE}"},
7+
{token_secret, "${TOKEN_SECRET}"},
88
{token_expiration, 86400},
99
{verification_code_expiration, 300},
1010
{password_code_expiration, 300},
1111
{checker_interval, 900000},
12-
{email_enabled, true},
12+
{email_enabled, false},
1313
{monthly_limits, #{slack => 100,
1414
email => 100,
1515
webhook => 100}},
1616
{pg_options, [{size, 10},
17-
{database, "holiday_ping"},
18-
{username, "holiday_ping"},
19-
{password, "holiday_ping"}]}
17+
{host, "${POSTGRES_HOST}"},
18+
{database, "${POSTGRES_DB}"},
19+
{username, "${POSTGRES_USER}"},
20+
{password, "${POSTGRES_PASSWORD}"}]}
2021
]},
2122
{throttle, [{rates, [{global_api_rate, 5, per_second},
2223
%% these rates have to also consider failed requests (e.g. 4xx responses)

docker/Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
########
2+
FROM clojure:lein-2.5.3
3+
4+
WORKDIR /opt/holiday_ping/priv/ui
5+
6+
COPY priv/ui .
7+
RUN lein deps
8+
RUN lein do clean, cljsbuild once min
9+
10+
##########
11+
FROM erlang:20.3.8.23-alpine
12+
13+
WORKDIR /opt/holiday_ping
14+
15+
RUN apk add --update bsd-compat-headers build-base git
16+
17+
COPY rebar.config rebar.lock ./
18+
RUN rebar3 compile
19+
20+
COPY conf conf
21+
COPY src src
22+
COPY --from=0 /opt/holiday_ping/priv/ui/resources/public priv/ui/resources/public
23+
RUN rebar3 compile
24+
RUN rebar3 as prod release tar
25+
RUN mkdir rel
26+
RUN tar -vxf _build/prod/rel/holiday_ping/*.tar.gz -C rel
27+
28+
#######
29+
FROM alpine:3.9
30+
31+
WORKDIR /opt/holiday_ping
32+
33+
RUN apk add --update ncurses
34+
35+
COPY --from=1 /opt/holiday_ping/rel .
36+
# COPY --from=1 /opt/holiday_ping/priv/ui priv/ui
37+
# COPY --from=1 /opt/holiday_ping/priv/ui /ui
38+
# COPY --from=1 /opt/holiday_ping/priv/ui bin/priv/ui
39+
40+
ENTRYPOINT ["/opt/holiday_ping/bin/holiday_ping"]
41+
CMD ["foreground"]

0 commit comments

Comments
 (0)