Skip to content

Commit 159ed05

Browse files
authored
Add Docker setup and testing documentation (#12)
- Created Dockerfile, entrypoint.sh, picture folder and .dockerignore in the root directory - Added test.md with detailed instructions on Docker setup and how to test the Docker container - Documented all testing procedures within test.md - Included a screenshot of the successful Docker build and test of docker container run in the pictures folder
1 parent 55b4116 commit 159ed05

File tree

6 files changed

+720
-0
lines changed

6 files changed

+720
-0
lines changed

.dockerignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
# Exclude Git repository files
3+
.git
4+
.gitignore
5+
6+
# Exclude Python cache
7+
__pycache__
8+
*.pyc
9+
*.pyo
10+
*.pyd
11+
12+
# Exclude Docker files
13+
Dockerfile
14+
docker-compose.yml
15+
16+
# Exclude logs and data
17+
logs/
18+
data/
19+
outputs/
20+
21+
# Exclude environment files
22+
.env

Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Use an official Ubuntu as a parent image
2+
FROM ubuntu:20.04
3+
4+
# Set environment variables to prevent interactive prompts during installation
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# Install system dependencies
8+
RUN apt-get update && apt-get install -y \
9+
wget \
10+
git \
11+
bzip2 \
12+
ca-certificates \
13+
libglib2.0-0 \
14+
libxext6 \
15+
libsm6 \
16+
libxrender1 \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
# Install Miniconda
20+
ENV CONDA_DIR=/opt/conda
21+
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh && \
22+
bash /tmp/miniconda.sh -b -p $CONDA_DIR && \
23+
rm /tmp/miniconda.sh && \
24+
$CONDA_DIR/bin/conda clean --all --yes
25+
26+
# Update PATH environment variable
27+
ENV PATH=$CONDA_DIR/bin:$PATH
28+
29+
# Create the Conda environment
30+
RUN conda create --name layer_skip python=3.10 -y
31+
32+
# Activate the Conda environment and install PyTorch and dependencies via Conda
33+
RUN echo "source activate layer_skip" >> ~/.bashrc
34+
ENV CONDA_DEFAULT_ENV=layer_skip
35+
ENV PATH=$CONDA_DIR/envs/layer_skip/bin:$PATH
36+
37+
# Install PyTorch CPU-only and other dependencies using Conda
38+
RUN conda install pytorch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 cpuonly -c pytorch -y
39+
40+
# Copy and install Python dependencies via pip (excluding torch, torchvision, torchaudio)
41+
COPY requirements.txt /app/requirements.txt
42+
RUN pip install --upgrade pip && \
43+
pip install --no-cache-dir -r /app/requirements.txt
44+
45+
# Copy the entire project into the Docker image
46+
COPY . /app
47+
48+
# Set the working directory
49+
WORKDIR /app
50+
51+
# Copy the entrypoint script
52+
COPY entrypoint.sh /entrypoint.sh
53+
RUN chmod +x /entrypoint.sh
54+
55+
# Expose any necessary ports (if applicable)
56+
# EXPOSE 8000
57+
58+
# Set the entrypoint
59+
ENTRYPOINT ["/entrypoint.sh"]

Picture/docker-test1.png

189 KB
Loading

Picture/dockerbuildsuccess.png

191 KB
Loading

entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
# entrypoint.sh
3+
4+
# Activate the Conda environment
5+
source /opt/conda/etc/profile.d/conda.sh
6+
conda activate layer_skip
7+
8+
# Export environment variables (e.g., HUGGINGFACE_TOKEN)
9+
export HUGGINGFACE_TOKEN=${HUGGINGFACE_TOKEN}
10+
11+
# Execute the passed command
12+
exec "$@"

0 commit comments

Comments
 (0)