-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔧refactor: Dockerfiles for use asdf and python3.11
- Loading branch information
1 parent
4631c32
commit b8d0c0e
Showing
3 changed files
with
94 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,54 @@ | ||
FROM ubuntu:22.04 | ||
MAINTAINER D10S0VSkY | ||
|
||
# Metadata | ||
MAINTAINER D10S0VSkY | ||
ENV LC_ALL=C.UTF-8 | ||
ENV LANG=C.UTF-8 | ||
ENV TZ=Europe/Madrid | ||
|
||
# Set up working directory | ||
WORKDIR /app | ||
ADD ./requirements.txt /app/requirements.txt | ||
|
||
# Create a user and group | ||
RUN groupadd --gid 10000 sld && \ | ||
useradd --uid 10000 --gid sld --shell /bin/bash --create-home sld | ||
useradd --uid 10000 --gid sld --shell /bin/bash --create-home sld | ||
|
||
# Set timezone | ||
RUN echo $TZ > /etc/timezone && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime | ||
|
||
|
||
# Install dependencies including build tools | ||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
apt-get update && \ | ||
apt-get upgrade -yq && \ | ||
apt-get -yq install \ | ||
python3.10 pip default-libmysqlclient-dev zip git tzdata && \ | ||
pip install --no-cache-dir -r requirements.txt | ||
apt-get update && \ | ||
apt-get -yq install curl git zip tzdata build-essential libssl-dev libffi-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev pkg-config libmysqlclient-dev | ||
|
||
RUN apt-get clean autoclean && \ | ||
apt-get autoremove -y && \ | ||
rm -rf /var/lib/{apt,dpkg,cache,log}/ | ||
|
||
# Install asdf, Python plugin, and Python version | ||
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.0 && \ | ||
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc && \ | ||
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
RUN . $HOME/.asdf/asdf.sh && \ | ||
asdf plugin add python && \ | ||
asdf install python 3.11.6 && \ | ||
asdf global python 3.11.6 | ||
|
||
|
||
# Install Python packages | ||
RUN . $HOME/.asdf/asdf.sh && \ | ||
python -m pip install --upgrade pip setuptools && \ | ||
python -m pip install --no-cache-dir -r requirements.txt | ||
|
||
# Clean up | ||
RUN apt-get clean autoclean && \ | ||
apt-get autoremove -y && \ | ||
rm -rf /var/lib/{apt,dpkg,cache,log} | ||
|
||
# Add the rest of the application | ||
ADD . /app/ | ||
RUN chown -R sld /app | ||
|
||
# Switch to user | ||
USER sld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,54 @@ | ||
FROM ubuntu:22.04 | ||
MAINTAINER D10S0VSkY | ||
|
||
# Metadata | ||
MAINTAINER D10S0VSkY | ||
ENV LC_ALL=C.UTF-8 | ||
ENV LANG=C.UTF-8 | ||
ENV TZ=Europe/Madrid | ||
ENV FLASK_APP run.py | ||
|
||
# Set up working directory | ||
WORKDIR /app | ||
ADD ./requirements.txt /app/requirements.txt | ||
|
||
# Create a user and group | ||
RUN groupadd --gid 10000 sld && \ | ||
useradd --uid 10000 --gid sld --shell /bin/bash --create-home sld | ||
|
||
COPY run.py gunicorn-cfg.py requirements.txt config.py .env ./ | ||
useradd --uid 10000 --gid sld --shell /bin/bash --create-home sld | ||
|
||
# Set timezone | ||
RUN echo $TZ > /etc/timezone && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime | ||
|
||
# Install dependencies including build tools | ||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
apt-get update && \ | ||
apt-get -yq install software-properties-common && \ | ||
add-apt-repository ppa:deadsnakes/ppa | ||
apt-get update && \ | ||
apt-get -yq install curl git zip tzdata build-essential libssl-dev libffi-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev pkg-config libmysqlclient-dev | ||
|
||
|
||
# Install asdf, Python plugin, and Python version | ||
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.0 && \ | ||
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc && \ | ||
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
RUN . $HOME/.asdf/asdf.sh && \ | ||
asdf plugin add python && \ | ||
asdf install python 3.11.6 && \ | ||
asdf global python 3.11.6 | ||
|
||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
apt-get update && \ | ||
apt-get upgrade -yq && \ | ||
apt-get -yq install \ | ||
python3.11 pip default-libmysqlclient-dev zip git tzdata python3.11-dev | ||
|
||
RUN ln -s /usr/bin/python3.11 /usr/bin/python && \ | ||
python -m pip install --upgrade setuptools && \ | ||
python -m pip install --no-cache-dir -r requirements.txt | ||
# Install Python packages | ||
RUN . $HOME/.asdf/asdf.sh && \ | ||
python -m pip install --upgrade pip setuptools && \ | ||
python -m pip install --no-cache-dir -r requirements.txt | ||
|
||
# Clean up | ||
RUN apt-get clean autoclean && \ | ||
apt-get autoremove -y && \ | ||
rm -rf /var/lib/{apt,dpkg,cache,log}/ | ||
apt-get autoremove -y && \ | ||
rm -rf /var/lib/{apt,dpkg,cache,log} | ||
|
||
# Add the rest of the application | ||
ADD . /app/ | ||
RUN chown -R sld /app | ||
|
||
# Switch to user | ||
USER sld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,53 @@ | ||
FROM ubuntu:22.04 | ||
MAINTAINER D10S0VSkY | ||
|
||
# Metadata | ||
MAINTAINER D10S0VSkY | ||
ENV LC_ALL=C.UTF-8 | ||
ENV LANG=C.UTF-8 | ||
ENV TZ=Europe/Madrid | ||
|
||
# Set up working directory | ||
WORKDIR /app | ||
ADD ./requirements.txt /app/requirements.txt | ||
|
||
# Create a user and group | ||
RUN groupadd --gid 10000 sld && \ | ||
useradd --uid 10000 --gid sld --shell /bin/bash --create-home sld | ||
useradd --uid 10000 --gid sld --shell /bin/bash --create-home sld | ||
|
||
# Set timezone | ||
RUN echo $TZ > /etc/timezone && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime | ||
|
||
# Install dependencies including build tools | ||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
apt-get update && \ | ||
apt-get -yq install software-properties-common && \ | ||
add-apt-repository ppa:deadsnakes/ppa | ||
apt-get update && \ | ||
apt-get -yq install curl git zip tzdata build-essential libssl-dev libffi-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev | ||
|
||
# Install asdf, Python plugin, and Python version | ||
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.0 && \ | ||
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc && \ | ||
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
RUN . $HOME/.asdf/asdf.sh && \ | ||
asdf plugin add python && \ | ||
asdf install python 3.11.6 && \ | ||
asdf global python 3.11.6 | ||
|
||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
apt-get update && \ | ||
apt-get upgrade -yq && \ | ||
apt-get -yq install \ | ||
python3.11 pip default-libmysqlclient-dev zip git tzdata python3.11-dev | ||
|
||
RUN ln -s /usr/bin/python3.11 /usr/bin/python && \ | ||
python -m pip install --upgrade setuptools && \ | ||
python -m pip install --no-cache-dir -r requirements.txt | ||
# Install Python packages | ||
RUN . $HOME/.asdf/asdf.sh && \ | ||
python -m pip install --upgrade pip setuptools && \ | ||
python -m pip install --no-cache-dir -r requirements.txt | ||
|
||
# Clean up | ||
RUN apt-get clean autoclean && \ | ||
apt-get autoremove -y && \ | ||
rm -rf /var/lib/{apt,dpkg,cache,log} | ||
apt-get autoremove -y && \ | ||
rm -rf /var/lib/{apt,dpkg,cache,log} | ||
|
||
# Add the rest of the application | ||
ADD . /app/ | ||
RUN chown -R sld /app | ||
|
||
# Switch to user | ||
USER sld |