-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
105 lines (83 loc) · 3.3 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
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
ARG PYTHON_VERSION="3.9.13"
ARG PLATFORM_NAME="linux/amd64"
FROM --platform=${PLATFORM_NAME} python:${PYTHON_VERSION}
# --- SYSTEM ARCHITECTURE
ARG TARGETPLATFORM
ARG TARGETARCH
ARG TARGETVARIANT
RUN printf "I'm building for TARGETPLATFORM=${TARGETPLATFORM}" \
&& printf ", TARGETARCH=${TARGETARCH}" \
&& printf ", TARGETVARIANT=${TARGETVARIANT} \n" \
&& printf "With uname -s : " && uname -s \
&& printf "and uname -m : " && uname -mm
# --- Environment variables
ENV REQUIREMENTS_FILE="requirements.txt"
ENV OUTDIR="/root"
ENV PROJECT_DIR="/opt/ml"
ENV PROGRAM_DIR="/opt/program"
ENV HOME_DIR="/root/ml"
ENV LOCAL_DEV_DIR="docker"
ENV ALIASES_FILE="/root/aliases.sh"
ENV DEBIAN_FRONTEND=noninteractive
ENV APP_SERVER_PORT=${APP_SERVER_PORT:-8001}
# --- Dockerfile Metadata
LABEL Maintainer="Victor Calderon"
# ------------------------- COPYING AND DIRECTORIES ---------------------------
RUN mkdir -p ${HOME_DIR}
COPY ./src ${PROJECT_DIR}/src
COPY ${LOCAL_DEV_DIR}/aliases.sh ${ALIASES_FILE}
COPY ${REQUIREMENTS_FILE} "${HOME_DIR}/${REQUIREMENTS_FILE}"
# ---------------------- EXPOSING PORTS FOR APP -------------------------------
EXPOSE 8001
# --------------------- INSTALLING EXTRA PACKAGES -----------------------------
# --- Updating packages and installing packages at the system-level
RUN apt-get -y update && \
apt-get upgrade -y && \
apt-get clean && \
# Instaling system-level packages
apt-get install -y \
git \
ssh \
tree \
git-flow \
tmux \
direnv \
bash-completion \
zsh \
htop \
vim \
&& \
# Cleaning out
rm -rf /var/lib/apt/lists/* && \
# Cleaning installs
apt-get clean && \
# Installing ZSH and OhZSH
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \
echo "source /etc/profile.d/bash_completion.sh" >> /root/.bashrc && \
echo "source /etc/profile.d/bash_completion.sh" >> /root/.zshrc && \
echo "source /root/aliases.sh" >> "${OUTDIR}/.zshrc" && \
echo "source /root/aliases.sh" >> "${OUTDIR}/.bashrc" && \
# Install direnv
echo 'eval "$(direnv hook zsh)"' >> "${OUTDIR}/.zshrc" && \
echo 'eval "$(direnv hook bash)"' >> "${OUTDIR}/.bash"
# -------------------------- DOCKER-SPECIFIC ----------------------------------
RUN apt-get update -y && \
cd ${OUTDIR_DOCKER} && \
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
# --------------------------- PYTHON-RELATED-LOCAL ----------------------------
RUN pip install --upgrade pip && \
python -m pip install -r "${HOME_DIR}/${REQUIREMENTS_FILE}"
# ----------------------------- PYTHON-SPECIFIC -------------------------------
# Set some environment variables. PYTHONUNBUFFERED keeps Python from
# buffering our standard output stream, which means that logs can be
# delivered to the user quickly. PYTHONDONTWRITEBYTECODE keeps Python
# from writing the .pyc files which are unnecessary in this case. We also
# update PATH so that the train and serve programs are found when the
# container is invoked.
ENV PYTHONUNBUFFERED=TRUE
ENV PYTHONDONTWRITEBYTECODE=TRUE
ENV PATH="${PROGRAM_DIR}:${PATH}"
ENV PYTHONPATH="${PROGRAM_DIR}:${PYTHONPATH}"
WORKDIR ${PROJECT_DIR}
CMD ["python", "src/app_service/app.py"]
# CMD ["uvicorn", "src.api.index:app", "--host", "0.0.0.0","--port", "7860"]