Skip to content

Instantly share code, notes, and snippets.

@ismail0352
Last active August 2, 2023 06:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ismail0352/e96d2cc94b71ef2324c9c0890ef7ca7f to your computer and use it in GitHub Desktop.
Save ismail0352/e96d2cc94b71ef2324c9c0890ef7ca7f to your computer and use it in GitHub Desktop.
Creating your own .deb file repo and host it using Nginx container with "autoindex on;"
FROM ubuntu as ubuntu
RUN apt-get update
RUN apt-get install -y dpkg-dev wget gnupg2 curl
ARG ubuntu_packages="wget htop default-jre-headless apt-transport-https nvidia-container-toolkit cuda-drivers libopengl0 linux-image-extra-virtual omnisci"
WORKDIR /opt/packages/deb
# Nvidia-Docker
RUN distribution=$(. /etc/os-release;echo $ID$VERSION_ID) && \
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add - && \
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list
# Cuda Drivers
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin && \
mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 && \
wget http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb && \
dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb && \
apt-key add /var/cuda-repo-10-1-local-10.1.243-418.87.00/7fa2af80.pub
RUN apt update
RUN chown -R _apt /opt/packages/deb/
RUN apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances $ubuntu_packages | grep "^\w" | sort -u)
RUN dpkg-scanpackages . | gzip -9c > Packages.gz
## For Local only mode uncomment below line:
# echo "Dir::Cache::Archives "/opt/packages/dep/";" | sudo tee -a /etc/apt/apt.conf
## BELOW commands needs to be run on Minion machines
# echo "deb [trusted=yes] http://localhost/deb/ ./" | tee -a /etc/apt/apt.conf
### OR ####
# echo "deb [trusted=yes] http://192.168.2.28:8083/deb/ ./" | tee -a /etc/apt/sources.list
######## This approach is the best #######
# cat /etc/apt/sources.list.d/test.list
# deb [trusted=yes] http://192.168.2.28:8083/deb/ ./
FROM centos as centos
WORKDIR /opt/packages/rpm
RUN yum install wget curl epel-release createrepo yum-utils -y
ARG centos_packages="kernel-devel wget htop java-1.8.0-openjdk-headless nvidia-container-toolkit cuda cuda-drivers"
# Nvidia-Docker
RUN distribution=$(. /etc/os-release;echo $ID$VERSION_ID) && \
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | tee /etc/yum.repos.d/nvidia-docker.repo
# Cuda
RUN wget http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-rhel7-10-1-local-10.1.243-418.87.00-1.0-1.x86_64.rpm && \
rpm -Uvh cuda-repo-rhel7-10-1-local-10.1.243-418.87.00-1.0-1.x86_64.rpm && \
yum clean expire-cache
RUN yum update -y
RUN yumdownloader --resolve $centos_packages
RUN createrepo --update --workers=4 .
## Local Changes for centos:
# Creating a Repo Example
# Create file /etc/yum.repos.d/test.repo
# [admin_console]
# name=Custom repository for test
# baseurl=http://192.168.2.28:8083/rpm/
# enabled=1
# gpgcheck=0
# printf "[test]\nname=Custom repository for test\nbaseurl=http://192.168.2.28:8083/rpm/\nenabled=1\ngpgcheck=0" >> /etc/yum.repos.d/test.repo
FROM nginx
RUN apt-get update
RUN apt install wget -y
COPY nginx_default.conf /etc/nginx/conf.d/default.conf
WORKDIR /usr/share/nginx/html
COPY --from=ubuntu /opt/packages/ .
COPY --from=centos /opt/packages/ .
WORKDIR /usr/share/nginx/html/others/
RUN wget https://artifacts.elastic.co/downloads/logstash/logstash-7.3.1.zip
########## Content of nginx_default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
autoindex on;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment