forked from DScheglov/ehealth.api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (47 loc) · 1.57 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
FROM nebo15/alpine-elixir:latest
# Maintainers
MAINTAINER Nebo#15 [email protected]
# Configure environment variables and other settings
ENV MIX_ENV=prod \
APP_NAME=ehealth \
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.
CMD $APP_NAME/bin/$APP_NAME foreground