From 7a4c62058757f40b07dfff3cec4020e1edd9a34c Mon Sep 17 00:00:00 2001 From: Tung Bui Date: Tue, 27 Feb 2024 22:55:17 +0700 Subject: [PATCH 1/6] docker: init dockerfile --- Dockerfile | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f138082 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,69 @@ +# Use the official Ubuntu 22.04 base image +ARG UBUNTU_VERSION=22.04 +FROM ubuntu:${UBUNTU_VERSION} + +# Set environment variables to avoid interactive installation prompts +ARG DEBIAN_FRONTEND=noninteractive +ARG TZ=UTC + +# Update and install required packages +RUN apt-get update && \ + apt-get install -y \ + software-properties-common \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg \ + lsb-release \ + tzdata \ + git \ + jq \ + curl \ + docker.io \ + postgresql-client \ + mysql-client \ + # Dev tools + build-essential \ + zlib1g-dev \ + libncurses5-dev \ + libgdbm-dev \ + libnss3-dev \ + libssl-dev \ + libreadline-dev \ + libffi-dev \ + libsqlite3-dev \ + wget \ + libbz2-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +## Set Python 3.11 as the default python version +RUN mkdir /tmp/python_env/ && \ + cd /tmp/python_env/ && \ + wget https://www.python.org/ftp/python/3.11.3/Python-3.11.3.tgz && \ + tar -xf Python-3.11.3.tgz && \ + cd Python-3.11.3 && \ + ./configure --enable-optimizations && \ + make -j$(nproc) && \ + make install && \ + cd / && \ + rm -rf /tmp/python_env/ + +# Install pip for Python 3.11 +RUN curl -k https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \ + python3.11 get-pip.py && \ + rm get-pip.py + +# Cleanup +RUN apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Reset environment variables +ENV DEBIAN_FRONTEND teletype +ENV TZ="" + +# Set the working directory +WORKDIR /root + +# Define the default command to run when the container starts +CMD ["/bin/bash"] From 554e9619af267f2ac3ce6c813194d5efab1938fe Mon Sep 17 00:00:00 2001 From: Tung Bui Date: Tue, 27 Feb 2024 22:58:41 +0700 Subject: [PATCH 2/6] doc: add docker build instruction --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index f49c769..b69edf8 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,34 @@ Before you begin, make sure you have [Docker](https://docs.docker.com/engine/install/) installed. It's also beneficial to have a basic understanding of Docker concepts. +## How to Build + +1. **Clone the Repository:** + + ```bash + git clone https://github.com/your-username/devops-toolkit.git + ``` + +2. **Navigate to the Repository:** + + ```bash + cd devops-toolkit + ``` + +3. **Navigate to the Repository:** + + ```bash + docker build -t devops-toolkit:latest . + ``` + +4. **Run the Docker Image (Optional):** + + ```bash + docker run --rm devops-toolkit + ``` + + + ## Contributing - See: [CONTRIBUTING.md](./CONTRIBUTING.md) From 300b6e5b1c98f0fb0162f798c72bd1752d066169 Mon Sep 17 00:00:00 2001 From: Tung Leo Date: Tue, 27 Feb 2024 23:04:23 +0700 Subject: [PATCH 3/6] docker: versioning python with ARG --- Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index f138082..f10db6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,12 +37,14 @@ RUN apt-get update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -## Set Python 3.11 as the default python version +# Set Python version as an argument +ARG PYTHON_VERSION=3.11.3 +# Install Python with specified version RUN mkdir /tmp/python_env/ && \ cd /tmp/python_env/ && \ - wget https://www.python.org/ftp/python/3.11.3/Python-3.11.3.tgz && \ - tar -xf Python-3.11.3.tgz && \ - cd Python-3.11.3 && \ + wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \ + tar -xf Python-${PYTHON_VERSION}.tgz && \ + cd Python-${PYTHON_VERSION} && \ ./configure --enable-optimizations && \ make -j$(nproc) && \ make install && \ From 451eb1d95861e7f0a35ee5c44a9f3a79c755a9cb Mon Sep 17 00:00:00 2001 From: Tung Bui Date: Tue, 27 Feb 2024 23:10:22 +0700 Subject: [PATCH 4/6] docker: update layer --- Dockerfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index f10db6b..b361ad0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,9 @@ ARG DEBIAN_FRONTEND=noninteractive ARG TZ=UTC # Update and install required packages -RUN apt-get update && \ - apt-get install -y \ +RUN apt-get update + +RUN apt-get install -y \ software-properties-common \ apt-transport-https \ ca-certificates \ @@ -19,9 +20,6 @@ RUN apt-get update && \ git \ jq \ curl \ - docker.io \ - postgresql-client \ - mysql-client \ # Dev tools build-essential \ zlib1g-dev \ From 35308fca55d6a9e2035c694bf91a4600f501970d Mon Sep 17 00:00:00 2001 From: Tung Bui Date: Tue, 27 Feb 2024 23:25:44 +0700 Subject: [PATCH 5/6] doc: init docs with troubleshooting content --- Dockerfile | 3 ++- docs/TROUBLESHOOTING.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 docs/TROUBLESHOOTING.md diff --git a/Dockerfile b/Dockerfile index b361ad0..be77ba3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,9 +6,10 @@ FROM ubuntu:${UBUNTU_VERSION} ARG DEBIAN_FRONTEND=noninteractive ARG TZ=UTC -# Update and install required packages +# Update RUN apt-get update +# Install required packages RUN apt-get install -y \ software-properties-common \ apt-transport-https \ diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md new file mode 100644 index 0000000..2be2b9a --- /dev/null +++ b/docs/TROUBLESHOOTING.md @@ -0,0 +1 @@ +- https://stackoverflow.com/questions/62154016/docker-on-wsl2-very-slow From b3bdb2848737b1b850b6436e2fd8c52dce9ce655 Mon Sep 17 00:00:00 2001 From: Tung Bui Date: Tue, 27 Feb 2024 23:40:09 +0700 Subject: [PATCH 6/6] doc: update guide --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b69edf8..0207b8b 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,17 @@ Before you begin, make sure you have [Docker](https://docs.docker.com/engine/ins 4. **Run the Docker Image (Optional):** - ```bash - docker run --rm devops-toolkit - ``` +- Start container + + ```bash + docker run -it --rm devops-toolkit + ``` + +- Check python version + + ```bash + docker run --rm devops-toolkit python3 --version + ```