-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.backup
87 lines (72 loc) · 2.85 KB
/
Dockerfile.backup
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
# The build-stage image:
FROM continuumio/miniconda3 AS build
# Update conda and install conda-pack:
RUN conda update conda && conda install -c conda-forge conda-pack
# Set conda mediapipe environment (time consuming step)
COPY environment.yml .
RUN conda env create -f environment.yml
# Use conda-pack to create a standalone enviornment in /venv:
RUN conda-pack -n mediapipe -o /tmp/env.tar \
&& mkdir /venv && cd /venv && tar xf /tmp/env.tar \
&& rm /tmp/env.tar
# We've put venv in same path it'll be in final image, so now fix up paths:
RUN /venv/bin/conda-unpack
##########################
# Create the base OS image (Ruby)
FROM ruby:3.1.2 AS base
# Define build arguments
ARG USER_ID=1001
ARG GROUP_ID=1001
# SET ENV/ARG/WKDIR PATH
ARG SETUSER="myuser"
ARG APP_ROOT="/home/${SETUSER}/local/app"
ARG CONDA_PKG="/home/${SETUSER}/local/conda_pkg"
RUN addgroup --gid ${GROUP_ID} ${SETUSER}
RUN adduser --disabled-password --gecos '' --uid ${USER_ID} --gid ${GROUP_ID} ${SETUSER}
RUN mkdir -p $APP_ROOT && mkdir -p CONDA_PKG
WORKDIR $APP_ROOT
# Copy /venv from the previous stage:
COPY --from=build /venv ${CONDA_PKG}
# Install ffmepg, wget, sqlite3, zip, python3-opencv
RUN apt-get -y update \
&& apt-get -y upgrade \
&& apt-get install -y --no-install-recommends ffmpeg \
&& apt-get install -y wget \
&& apt-get install -y sqlite3 \
&& apt-get install -y zip \
&& apt-get install -y python3-opencv nano
RUN apt-get update && apt-get install -y \
curl \
build-essential \
graphviz \
libmariadb-dev &&\
curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y nodejs yarn
# Redis installation
RUN apt-get install -y lsb-release \
&& curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list \
&& apt-get -y update \
&& apt-get install -y redis \
&& rm -rf /var/lib/apt/lists/*
# Set wkdir & Install required packages
COPY ./src/ $APP_ROOT
#ENV RAILS_ENV production
RUN yarn install
RUN gem install rails && bundle install
RUN rails db:create db:migrate assets:precompile
# Set user permission
ENV SETUSER_ $SETUSER
#RUN useradd -m $SETUSER_ \
# && chown -R $SETUSER_:$SETUSER_ $APP_ROOT
RUN chown -R ${USER_ID}:${GROUP_ID} $APP_ROOT
USER $SETUSER_
# Clean cache and Entry with conda mediapipe env
# RUN rails tmp:cache:clear && rails db:reset
ENV CONDA_PKG_ $CONDA_PKG
SHELL ["/bin/bash", "-c"]
RUN source $CONDA_PKG_/bin/activate
EXPOSE 13006
ENTRYPOINT foreman s -f Procfile.backup