-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* File no longer needed * File not updated and not needed * Add dockerignore * Remove unused production requirements * Update to use venv * New multi-stage slim dockerfile * Not needed anymore
- Loading branch information
1 parent
31fb739
commit 067dcca
Showing
7 changed files
with
79 additions
and
118 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
venv/ | ||
env/ | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
__pycache__/ | ||
*.so | ||
*.egg | ||
*.egg-info/ | ||
.eggs/ | ||
.git/ | ||
.gitignore | ||
.DS_Store | ||
Thumbs.db | ||
*.log | ||
*.swp | ||
*.tmp | ||
build/ | ||
dist/ | ||
*.egg-info/ | ||
*.tar.gz | ||
*.zip | ||
node_modules/ | ||
.idea/ | ||
.vscode/ | ||
*.sublime-project | ||
*.sublime-workspace | ||
.dockerignore | ||
Dockerfile | ||
Dockerfile_MacM1 | ||
images/ | ||
.github | ||
data/ |
This file was deleted.
Oops, something went wrong.
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,59 +1,68 @@ | ||
FROM python:3.12-slim | ||
LABEL org.opencontainers.image.title="AIP" \ | ||
org.opencontainers.image.description="This image runs the AIP framework for blocklist generation." \ | ||
org.opencontainers.image.version="0.1.0" \ | ||
org.opencontainers.image.created="2023-08-01" \ | ||
org.opencontainers.image.source="https://github.com/stratosphereips/AIP" \ | ||
org.opencontainers.image.source="Joaquin Bogado <[email protected]>" \ | ||
org.opencontainers.image.authors="Veronica Valeros <[email protected]>" | ||
|
||
FROM python:3.12-slim AS builder | ||
|
||
# Define arguments for username, UID, and GID | ||
# Create a non-root user | ||
ARG username=aip | ||
ARG uid=1000 | ||
ARG gid=1000 | ||
|
||
# Set environment variables based on these arguments | ||
ENV USER=$username | ||
ENV UID=$uid | ||
ENV GID=$gid | ||
ENV HOME=/home/$USER | ||
|
||
# Create a group and user based on the UID and GID | ||
RUN apt-get update && \ | ||
apt-get install -y python3-venv && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN groupadd -g $GID $USER && \ | ||
useradd -m -u $UID -g $GID -s /bin/bash $USER | ||
|
||
COPY etc/docker/entrypoint.sh /usr/local/bin/ | ||
RUN chmod u+x /usr/local/bin/entrypoint.sh | ||
|
||
# Switch to the non-root user | ||
USER $USER | ||
ENV PATH="$HOME/miniconda3/bin:$PATH" | ||
ENV ENV_PREFIX=$HOME/env | ||
|
||
WORKDIR $HOME/AIP | ||
|
||
COPY requirements.txt . | ||
|
||
# Conda installation and setup | ||
RUN python -c "import urllib.request; urllib.request.urlretrieve('https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh', '$HOME/miniconda.sh')" && \ | ||
bash ~/miniconda.sh -b -p $HOME/miniconda3 && \ | ||
rm ~/miniconda.sh | ||
RUN python -m venv venv && \ | ||
./venv/bin/pip install --no-cache-dir -r requirements.txt | ||
|
||
RUN conda init bash | ||
# Remove unnecessary files | ||
RUN find venv/ -type d -name '__pycache__' -exec rm -rf {} + | ||
RUN find venv/ -type d -name 'tests' -exec rm -rf {} + && \ | ||
find venv/ -type d -name '*.dist-info' -exec rm -rf {} + | ||
|
||
# Set the working directory | ||
WORKDIR $HOME/AIP | ||
# Stage 2: Final stage | ||
FROM python:3.12-slim | ||
|
||
# Create a non-root user | ||
ARG username=aip | ||
ARG uid=1000 | ||
ARG gid=1000 | ||
|
||
COPY environment.yml requirements.txt $HOME/AIP/ | ||
ENV USER=$username | ||
ENV UID=$uid | ||
ENV GID=$gid | ||
ENV HOME=/home/$USER | ||
|
||
RUN groupadd -g $GID $USER && \ | ||
useradd -m -u $UID -g $GID -s /bin/bash $USER | ||
|
||
RUN conda update --name base conda | ||
RUN conda env create --file environment.yml && \ | ||
conda clean --all --yes | ||
# Copy the entrypoint script | ||
COPY etc/docker/entrypoint.sh /usr/local/bin/ | ||
RUN chmod u+x /usr/local/bin/entrypoint.sh | ||
|
||
# Switch to the non-root user | ||
USER $USER | ||
|
||
WORKDIR $HOME/AIP | ||
|
||
# Copy application | ||
COPY . . | ||
# Copy venv from the builder stage | ||
COPY --from=builder $HOME/AIP/venv $HOME/AIP/venv | ||
|
||
# Dynamically link aip to the correct site-packages folder | ||
RUN ln -s $HOME/AIP/lib/aip $(conda run -n aip python -c "import site; print(site.getsitepackages()[0])")/aip | ||
# Copy aip files | ||
COPY --chown=$USER:$USER . . | ||
|
||
RUN echo 'conda activate aip' >> $HOME/.bashrc | ||
ENV PATH="$HOME/AIP/venv/bin:$PATH" | ||
|
||
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ] |
This file was deleted.
Oops, something went wrong.
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
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,10 +1,6 @@ | ||
netaddr==0.8.0 | ||
maxminddb==2.2.0 | ||
zeeklog2pandas | ||
ipython | ||
scikit-learn | ||
pathlib | ||
joblib | ||
python-dotenv | ||
matplotlib | ||
pandas |
This file was deleted.
Oops, something went wrong.