{"id":14155272,"url":"https://github.com/Jaffa-Cakes/dockerfile-snippets","last_synced_at":"2025-08-06T01:30:47.651Z","repository":{"id":208827241,"uuid":"722572862","full_name":"Jaffa-Cakes/dockerfile-snippets","owner":"Jaffa-Cakes","description":"Dockerfile snippets to automatically install and configure software in Docker containers and VS Code Dev Containers.","archived":false,"fork":false,"pushed_at":"2023-12-06T14:13:35.000Z","size":6,"stargazers_count":20,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-17T08:05:00.211Z","etag":null,"topics":["devcontainer","docker","snippets","vscode"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jaffa-Cakes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-11-23T12:44:38.000Z","updated_at":"2024-01-14T13:01:26.000Z","dependencies_parsed_at":"2023-11-23T14:27:36.035Z","dependency_job_id":"74314169-e1c5-4baf-9bff-5ac9a3a18c51","html_url":"https://github.com/Jaffa-Cakes/dockerfile-snippets","commit_stats":null,"previous_names":["jaffa-cakes/dockerfile-snippets"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaffa-Cakes%2Fdockerfile-snippets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaffa-Cakes%2Fdockerfile-snippets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaffa-Cakes%2Fdockerfile-snippets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaffa-Cakes%2Fdockerfile-snippets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jaffa-Cakes","download_url":"https://codeload.github.com/Jaffa-Cakes/dockerfile-snippets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228821400,"owners_count":17977165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["devcontainer","docker","snippets","vscode"],"created_at":"2024-08-17T08:02:37.395Z","updated_at":"2024-12-09T02:31:12.278Z","avatar_url":"https://github.com/Jaffa-Cakes.png","language":null,"funding_links":[],"categories":["vscode"],"sub_categories":[],"readme":"# Dockerfile Snippets\n\nThese snippets are tested on `debian:bookworm` based images.\nThey should help save time when creating Dockerfiles, especially for [VS Code Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers).\n\n### Other Pages\n\n- [pgAdmin](pgadmin.md)\n\n### Contributing\n\nIf you have any suggestions or improvements, please feel free to open an issue or pull request.\nUseful snippets are always welcome.\n\n## Table of Contents\n\n- [Dockerfile Snippets](#dockerfile-snippets)\n    - [Other Pages](#other-pages)\n    - [Contributing](#contributing)\n  - [Table of Contents](#table-of-contents)\n  - [Install PostgreSQL](#install-postgresql)\n  - [Update and Upgrade Packages](#update-and-upgrade-packages)\n  - [Install Common Packages](#install-common-packages)\n  - [Install Zsh/Oh My Zsh](#install-zshoh-my-zsh)\n  - [Install Node.js and NPM](#install-nodejs-and-npm)\n  - [Install Docker with Host Socket](#install-docker-with-host-socket)\n\n\n## Install PostgreSQL\n\n```Dockerfile\n######################################\n### START # Install PostgreSQL #######\n######################################\n\n# Set PostgreSQL version\nARG POSTGRESQL_MAJOR=16\n\n# Install Dependencies\nRUN apt install -y wget\n\n# Create the file repository configuration:\nRUN sh -c 'echo \"deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main\" \u003e /etc/apt/sources.list.d/pgdg.list'\n\n# Import the repository signing key:\nRUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -\n\n# Update the package lists:\nRUN apt update\n\n# Install PostgreSQL.\nRUN apt -y install postgresql-${POSTGRESQL_MAJOR}\n\n# Set locale\nENV LC_ALL=C\n\n# Set postgres password\nRUN service postgresql start \u0026\u0026 \\\n    su -c \"psql -c \\\"ALTER USER postgres PASSWORD 'postgres';\\\"\" - postgres \u0026\u0026 \\\n    service postgresql stop\n\n# Allow remote connections\nRUN echo \"host all all 0.0.0.0/0 md5\" \u003e\u003e /etc/postgresql/16/main/pg_hba.conf \u0026\u0026 \\\n    echo \"listen_addresses='*'\" \u003e\u003e /etc/postgresql/16/main/postgresql.conf \u0026\u0026 \\\n    sed -i 's/local   all             postgres                                peer/local   all             postgres                                md5/' /etc/postgresql/16/main/pg_hba.conf\n\n```\n\nTo start the server, these commands can be used with a shell script entrypoint:\n\n```bash\n# Adjust ownership\nchown -R postgres:postgres /var/lib/postgresql/16/main\n\n# Start the postgres server\nservice postgresql start\n\n# Tail the PostgreSQL log file to keep the container running\ntail -f /var/log/postgresql/postgresql-16-main.log\n```\n\nThese commands could also be added to the Dockerfile if you prefer.\n\n## Update and Upgrade Packages\n\n```Dockerfile\n##################################\n### START # Update and Upgrade ###\n##################################\n\nRUN apt update \\\n    \u0026\u0026 apt upgrade -y\n\n##################################\n### END # Update and Upgrade #####\n##################################\n```\n\n## Install Common Packages\n\n```Dockerfile\n#######################################\n### START # Install Common Packages ###\n#######################################\n\nRUN apt install -y build-essential curl wget git vim nano unzip zip gnupg2 apt-transport-https ca-certificates lsb-release software-properties-common\n\n#######################################\n### END # Install Common Packages #####\n#######################################\n```\n\n## Install Zsh/Oh My Zsh\n\n```Dockerfile\n#####################################\n### START # Install Zsh/Oh My Zsh ###\n#####################################\n\n# Base install of Zsh with Oh My Zsh\nRUN apt install -y zsh \\\n    \u0026\u0026 sh -c \"$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)\" --unattended\n\n# Install Zsh plugins\nRUN git clone https://github.com/zsh-users/zsh-autosuggestions $HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions \\\n    \u0026\u0026 git clone https://github.com/zsh-users/zsh-syntax-highlighting $HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting \\\n    \u0026\u0026 git clone https://github.com/zsh-users/zsh-history-substring-search $HOME/.oh-my-zsh/custom/plugins/zsh-history-substring-search\n\n# Configure Zsh to use plugins\nRUN sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-history-substring-search history aliases sudo themes docker nmap kubectl)/' $HOME/.zshrc \\\n    \u0026\u0026 sed -i 's/ZSH_THEME=\"robbyrussell\"/ZSH_THEME=\"af-magic\"/' $HOME/.zshrc\n\n# Set Zsh as default shell\nRUN chsh -s /usr/bin/zsh\n\n#####################################\n### END # Install Zsh/Oh My Zsh #####\n#####################################\n```\n\n## Install Node.js and NPM\n\nYou can change the `NODE_MAJOR` argument to the version you want to install.\n\n```Dockerfile\n#######################################\n### START # Install Node.js and NPM ###\n#######################################\n\nARG NODE_MAJOR=20\n\nRUN set -uex; \\\n    mkdir -p /etc/apt/keyrings; \\\n    curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \\\n    | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \\\n    echo \"deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main\" \\\n    \u003e /etc/apt/sources.list.d/nodesource.list; \\\n    apt -y update; \\\n    apt -y install nodejs;\n\n#######################################\n### END # Install Node.js and NPM #####\n#######################################\n```\n\n## Install Docker with Host Socket\n\n```Dockerfile\n###############################################\n### START # Install Docker with Host Socket ###\n###############################################\n\n# Set docker host socket\nENV DOCKER_HOST=unix:///var/run/docker-host.sock\n\n# Install Docker\nRUN apt install -y lsb-release \\\n    \u0026\u0026 curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - \\\n    \u0026\u0026 echo \"deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable\" | tee /etc/apt/sources.list.d/docker.list \u003e /dev/null \\\n    \u0026\u0026 apt update \\\n    \u0026\u0026 apt install -y docker-ce docker-ce-cli containerd.io\n\n# Add user to docker group if it doesn't exist and add user to it\nRUN if getent group docker \u003e /dev/null 2\u003e\u00261; then \\\n    echo \"Docker group exists\"; \\\n    else \\\n    groupadd docker; \\\n    fi \\\n    \u0026\u0026 usermod -aG docker root\n\n###############################################\n### END # Install Docker with Host Socket #####\n###############################################\n```\n\nIf you are using this for a VS Code devcontainer, you should add the following to your `.devcontainer/devcontainer.json` file to allow the container to access the host socket:\n\n```json\n\"mounts\": [\n    \"source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind\"\n]\n```\n\nIf you are using the `docker-compose.yml` file to allow the container to access the host socket, you can instead add the following to your `docker-compose.yml` file under the `volumes` section if the container:\n\n```yaml\nvolumes:\n  - /var/run/docker.sock:/var/run/docker-host.sock\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJaffa-Cakes%2Fdockerfile-snippets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJaffa-Cakes%2Fdockerfile-snippets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJaffa-Cakes%2Fdockerfile-snippets/lists"}