-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
108 lines (82 loc) · 3.29 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
106
107
108
# syntax=docker/dockerfile:1
# ........................................................
# Backend base image
# ........................................................
#FROM python:3.12.3-alpine3.20 as base
FROM python:3.12-slim-bookworm as base
LABEL maintainer="KU Biodiversity Institute <github.com/lifemapper/bison>"
RUN apt-get update
RUN apt-get install -y awscli
RUN apt-get install -y gcc
RUN apt-get install -y git
RUN apt-get install -y vim
RUN addgroup --gid 888 bison \
&& adduser --ingroup bison --uid 888 bison
RUN mkdir -p /home/bison \
&& chown bison.bison /home/bison
RUN mkdir -p /scratch-path/log \
&& mkdir -p /scratch-path/sessions \
&& chown -R bison.bison /scratch-path
# Run everything as the user 'bison'
WORKDIR /home/bison
USER bison
COPY --chown=bison:bison ./requirements.txt .
# Set up a virtual environment
RUN python3 -m venv venv \
&& venv/bin/pip install --upgrade pip \
&& venv/bin/pip install --no-cache-dir -r ./requirements.txt
# This assumes that the bison repository is present on the host machine and
# docker is run from the top of the repo directory (with bison subdir directly below).
COPY --chown=bison:bison ./bison ./bison
COPY --chown=bison:bison ./data ./data
# ........................................................
# Task image from base
# ........................................................
FROM base as task
# Install dev dependencies for debugging
RUN venv/bin/pip install debugpy
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE 1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1
COPY --chown=bison:bison ./config/aws.conf ./.aws/config
#CMD /bin/sh
#CMD tail -f /dev/null
CMD venv/bin/python -m ${TASK_APP}
# ........................................................
# Development flask image from base
# ........................................................
FROM base as dev-flask
# Install dev dependencies for debugging
RUN venv/bin/pip install debugpy
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE 1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1
ENV FLASK_DEBUG=True
# Logs in the window where the docker command is executed
CMD venv/bin/python -m debugpy --listen 0.0.0.0:${DEBUG_PORT} -m ${FLASK_MANAGE} run --host=0.0.0.0
# ........................................................
# Production flask image from base
# ........................................................
FROM base as flask
COPY --chown=bison:bison ./flask_app ./flask_app
#ENV FLASK_ENV=production
CMD venv/bin/python -m gunicorn -w 4 --bind 0.0.0.0:5000 ${FLASK_APP}
# ........................................................
# Frontend base image (for development)
# ........................................................
FROM node:16.10.0-buster as base-front-end
LABEL maintainer="Specify Collections Consortium <github.com/specify>"
USER node
WORKDIR /home/node
COPY --chown=node:node bison/frontend/js_src/package*.json ./
RUN npm install
RUN mkdir dist \
&& chown node:node dist
COPY --chown=node:node bison/frontend/js_src .
# ........................................................
# Frontend image (for production) from base-front-end
# ........................................................
FROM base-front-end as front-end
RUN npm run build