-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
67 lines (54 loc) · 1.99 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
FROM nebo15/alpine-elixir:1.4.1-r0
# Maintainers
MAINTAINER Nebo#15 support@nebo15.com
# Configure environment variables and other settings
ENV MIX_ENV=prod \
APP_NAME=gateway_api \
APP_PORT=4000
WORKDIR ${HOME}
# Install and compile project dependencies
COPY mix.* ./
RUN mix do deps.get, deps.compile
# Add project sources
COPY . .
# Compile project for Erlang VM
RUN mix do compile, release --verbose
# Move release to /opt/$APP_NAME
RUN \
mkdir -p $HOME/priv && \
mkdir -p /opt/$APP_NAME/log && \
mkdir -p /var/log && \
mkdir -p /opt/$APP_NAME/priv && \
mkdir -p /opt/$APP_NAME/hooks && \
mkdir -p /opt/$APP_NAME/uploads && \
cp -R $HOME/priv /opt/$APP_NAME/ && \
cp -R $HOME/bin/hooks /opt/$APP_NAME/ && \
APP_TARBALL=$(find $HOME/_build/$MIX_ENV/rel/$APP_NAME/releases -maxdepth 2 -name ${APP_NAME}.tar.gz) && \
cp $APP_TARBALL /opt/$APP_NAME/ && \
cd /opt/$APP_NAME && \
tar -xzf $APP_NAME.tar.gz && \
rm $APP_NAME.tar.gz && \
rm -rf /opt/app/* && \
chmod -R 777 $HOME && \
chmod -R 777 /opt/$APP_NAME && \
chmod -R 777 /var/log
# Change user to "default"
USER default
# Allow to read ENV vars for mix configs
ENV REPLACE_OS_VARS=true
# Exposes this port from the docker container to the host machine
EXPOSE ${APP_PORT}
# Change workdir to a released directory
WORKDIR /opt
# Pre-run hook that allows you to add initialization scripts.
# All Docker hooks should be located in bin/hooks directory.
RUN $APP_NAME/hooks/pre-run.sh
# The command to run when this image starts up
# You can run it in one of the following ways:
# Interactive: gateway_api/bin/gateway_api console
# Foreground: gateway_api/bin/gateway_api foreground
# Daemon: gateway_api/bin/gateway_api start
# Also you can run migrations whenever container starts:
# gateway_api/bin/gateway_api command gateway_api_tasks migrate!
# Alternatively you can set env APP_MIGRATE=true and APP_RUN_SEED=true when starting container.
CMD $APP_NAME/bin/$APP_NAME foreground