Skip to content

Commit

Permalink
added python devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
hadirgax committed Mar 31, 2024
1 parent 3928580 commit a71ac22
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/miniconda_ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Miniconda Ubuntu Jammy Image
name: Build Miniconda Ubuntu Jammy Devcontainer Image
on:
push:
branches:
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/python_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build Python Bookworm Devcontainer Image
on:
push:
branches:
- main
paths:
- 'devcontainer_images/src/python/Dockerfile'
- '.github/workflows/python_ci.yml'
pull_request:
paths:
- 'devcontainer_images/src/python/Dockerfile'
- '.github/workflows/python_ci.yml'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- name: Login to DockerHub
uses: docker/[email protected]
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags')
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up QEMU
uses: docker/[email protected]
with:
platforms: linux/amd64

- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
with:
version: latest
driver-opts: network=host

- name: Docker meta
id: meta
uses: docker/[email protected]
with:
images: hadirgax/devcontainer-python
tags: |
type=ref,event=branch
- name: build python
uses: docker/[email protected]
with:
context: ./devcontainer_images/src/python
builder: ${{ steps.buildx.outputs.name }}
file: ./devcontainer_images/src/python/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags') }}
1 change: 1 addition & 0 deletions devcontainer_images/src/miniconda/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ RUN set -eux; \
gnupg \
libcurl?-openssl-dev \
libexpat1-dev \
libfontconfig1 \
libglib2.0-0 \
libpcre2-dev \
libsm6 \
Expand Down
83 changes: 83 additions & 0 deletions devcontainer_images/src/python/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# [Choice] Python version from https://hub.docker.com/_/python
FROM python:3.12-slim-bookworm

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONFAULTHANDLER 1

# hadolint ignore=DL3008
RUN set -eux; \
apt-get update -q && \
apt-get install -q -y --no-install-recommends \
bzip2 \
build-essential \
ca-certificates \
curl \
gettext \
gnupg \
libcurl?-openssl-dev \
libexpat1-dev \
libfontconfig1 \
libglib2.0-0 \
libpcre2-dev \
libsm6 \
libssl-dev \
libxext6 \
libxrender1 \
netbase \
openssh-client \
procps \
p7zip-full \
subversion \
sudo \
tar \
wget \
zip \
zlib1g-dev \
zsh \
&& apt-get upgrade -yq \
&& update-ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ARG GIT_VERSION=2.44.0
RUN curl -sL https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz | tar -xzC /tmp 2>&1 && \
cd /tmp/git-${GIT_VERSION} && \
make -s USE_LIBPCRE=YesPlease prefix=/usr/local sysconfdir=/etc all && \
make -s USE_LIBPCRE=YesPlease prefix=/usr/local sysconfdir=/etc install 2>&1 && \
rm -rf /tmp/git-${GIT_VERSION} && \
rm -rf /var/lib/apt/lists/*

ARG USERNAME=devcon
ARG USER_GID=1000
ARG USER_HOME="/home/${USERNAME}"
RUN groupadd --gid ${USER_GID} ${USERNAME} && \
useradd -s /bin/bash --gid ${USER_GID} -m ${USERNAME} && \
echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} && \
chmod 0440 /etc/sudoers.d/${USERNAME}

RUN OMZ_DIR=${USER_HOME}/.oh-my-zsh && \
umask g-w,o-w && \
mkdir -p "${OMZ_DIR}" && \
git clone --depth=1 \
-c core.eol=lf \
-c core.autocrlf=false \
-c fsck.zeroPaddedFilemode=ignore \
-c fetch.fsck.zeroPaddedFilemode=ignore \
-c receive.fsck.zeroPaddedFilemode=ignore \
"https://github.com/ohmyzsh/ohmyzsh" "${OMZ_DIR}" 2>&1 && \
ZSHRC_TEMPLATE_FILE="${OMZ_DIR}/templates/zshrc.zsh-template" && \
echo "$(cat "${ZSHRC_TEMPLATE_FILE}")\nDISABLE_AUTO_UPDATE=false\nDISABLE_UPDATE_PROMPT=false" > ${USER_HOME}/.zshrc && \
cd ${OMZ_DIR} && \
git repack -a -d -f --depth=1 --window=1 && \
echo "auth sufficient pam_rootok.so" >> /etc/pam.d/chsh && \
chsh --shell /bin/zsh ${USERNAME} && \
chown -R ${USER_GID}:${USERNAME} ${USER_HOME}/.zshrc

CMD [ "/bin/bash" ]

ARG VENV_PATH="/home/devcon/venv"
RUN su devcon -c "python -m venv ${VENV_PATH}" \
&& su devcon -c "${VENV_PATH}/bin/pip --disable-pip-version-check --no-cache-dir install --upgrade \
setuptools~=69.0.3 \
gitpython~=3.1.41
3 changes: 3 additions & 0 deletions vscode_pack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# The [@hadirgax](https://github.com/hadirgax) VSCode Extension Pack

This is the extension pack that includes all the extensions I use daily.

0 comments on commit a71ac22

Please sign in to comment.