-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile.ubuntu24.04
90 lines (72 loc) · 2.64 KB
/
Dockerfile.ubuntu24.04
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
# For local development and testing only.
FROM ubuntu:24.04
# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive
# Set environment variables
ENV PYENV_ROOT=/root/.pyenv
ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
# Update and install dependencies
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y \
# Essential build tools
build-essential \
# Libraries for building Python
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
# Additional libraries that some Python packages might need
libncursesw5-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
# Useful tools
wget curl git vim sudo \
# App specific dependencies
wkhtmltopdf \
xauth \
xvfb \
# PostgreSQL
postgresql \
libpq-dev \
# Redis
redis-server \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create a new user "devuser" with user ID 1000
RUN useradd -m -s /bin/bash -u 1000 devuser
# Add the user to the sudo group
RUN usermod -aG sudo devuser
# Set up password-less sudo for the user
RUN echo "devuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Switch to the new user
USER devuser
# Install pyenv
RUN curl https://pyenv.run | bash
# Add pyenv initialization to bash profile
RUN echo 'eval "$(pyenv init -)"' >> ~/.bashrc
# Install Python versions
RUN pyenv install 2.7.18
# Set global Python version
RUN pyenv global 2.7.18
# Start PostgreSQL, set a password and create eaa database
USER postgres
RUN service postgresql start && \
psql -c "ALTER USER postgres PASSWORD 'password';" && \
psql -c "CREATE ROLE eaa WITH LOGIN PASSWORD 'password';" && \
psql -c "CREATE DATABASE donations;" && \
psql -c "GRANT ALL PRIVILEGES ON DATABASE donations TO eaa;"
USER devuser
# Upgrade pip to the last version that supports Python 2.7 and install the last
# version of virtualenv that works for Python 2.7
RUN pip install --upgrade "pip<21.0" && \
pip install virtualenv==16.7.10
# Install nvm and node
ENV NVM_DIR=/root/.nvm
RUN mkdir $NVM_DIR && \
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash && \
. $NVM_DIR/nvm.sh && nvm install 8.14.0
# Copy over python dependencies
# COPY deps deps
# Create and activate a Python virtual environment and install the dependencies
# RUN virtualenv donation_portal_env && \
# . donation_portal_env/bin/activate && \
# pip install -r deps/pip.base && \
# pip install -r deps/pip
# Document that the service listens on port 8000. Note, this doesn't actually
# open the port - you'll need to run `docker run -p 8000:8000 <image name>`.
EXPOSE 8000