Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
151 lines (132 loc) · 9 KB
/
Copy pathDockerfile
File metadata and controls
151 lines (132 loc) · 9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
FROM mcr.microsoft.com/devcontainers/php:8.3
# The php base image sets WORKDIR to /var/www/html, which devcontainer_on_create.sh
# later deletes and replaces with a symlink to the mounted docroot. The devcontainer
# CLI starts its persistent setup shell ("shellServer") in WORKDIR with no -w flag, so
# that deletion orphans the shell's cwd and the subsequent dotfiles `git clone` fails
# with "Unable to read current working directory" (issue #45). Anchor WORKDIR to a
# stable directory that the lifecycle scripts never delete.
WORKDIR /home/vscode
# Set umask to 002 system-wide so files stay group-writable for the www-data web
# server. We can't rely on per-user shell rc files: developers often symlink their
# own ~/.zshrc/~/.bashrc from a personal dotfiles repo, overwriting our edits. And
# pam_umask only fires for login PAM sessions, which the VS Code-spawned terminals
# and `exec`s in this devcontainer don't open. So set it in the system shell files:
# - /etc/zsh/zshenv sourced by EVERY zsh invocation (login/non-login, interactive/not)
# - /etc/bash.bashrc sourced by interactive non-login bash (VS Code terminals)
# - /etc/profile.d/umask.sh sourced by login shells (sh and bash)
# Note: non-interactive bash (e.g. `bash -c`, scripts) has no equivalent hook, but
# tooling such as drush runs under zsh, which /etc/zsh/zshenv covers completely.
# pam_umask is left in place as a backstop for real PAM sessions (ssh, su, cron).
RUN sed -i 's/pam_umask\.so/pam_umask.so umask=002/' /etc/pam.d/common-session \
&& sed -i 's/pam_umask\.so/pam_umask.so umask=002/' /etc/pam.d/common-session-noninteractive \
&& echo "umask 002" >> /etc/zsh/zshenv \
&& echo "umask 002" >> /etc/bash.bashrc \
&& echo "umask 002" > /etc/profile.d/umask.sh
RUN usermod -aG www-data vscode
# Add glow for formatting command usage output (and because it's just nice)
RUN mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://repo.charm.sh/apt/gpg.key | gpg --dearmor -o /etc/apt/keyrings/charm.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | tee /etc/apt/sources.list.d/charm.list
# Install MariaDB and Redis and PHP (incl Apache) and Cypress dependencies and Terraform and AWS CLI
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get install -y libpng-dev libzip-dev libicu-dev libjpeg62-turbo-dev libwebp-dev \
&& docker-php-ext-install mysqli pdo pdo_mysql intl \
&& docker-php-ext-configure gd --with-jpeg --with-webp \
&& docker-php-ext-install gd \
&& pecl install redis zip \
&& docker-php-ext-enable redis zip \
&& apt-get install -y mariadb-client redis-tools mkdocs-material mkdocs-material-extensions \
&& apt-get install -y npm libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2 libxtst6 xauth xvfb \
&& apt-get install -y dnsutils fd-find fzf glow lazygit luarocks pv ripgrep tmux vivid \
&& apt-get install -y gnupg \
&& wget -O- https://apt.releases.hashicorp.com/gpg | \
gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null \
&& gpg --no-default-keyring \
--keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg \
--fingerprint \
&& echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
sudo tee /etc/apt/sources.list.d/hashicorp.list > /dev/null \
&& apt update \
&& apt-get install -y awscli azure-cli terraform \
# Terraform is installed; drop the HashiCorp repo so future apt-get updates
# (devcontainer features, developers) don't break when HashiCorp rotates keys.
&& rm -f /etc/apt/sources.list.d/hashicorp.list /usr/share/keyrings/hashicorp-archive-keyring.gpg \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
# `aws ssm start-session` shells out to a separate binary and fails with
# "SessionManagerPlugin is not found" without it, so the CLI above is only half
# the tool. AWS publishes no apt repository, no GPG key and no checksum for this
# — an unsigned .deb from an S3 bucket is the documented install, and their own
# verification step is running the binary to see if it prints success. The
# --version call below is that check, at build time, so a bad download breaks
# the image rather than someone's session.
RUN curl -fsSL "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_`uname -m | sed s/x86_64/64bit/ | sed s/aarch64/arm64/`/session-manager-plugin.deb" \
-o /tmp/session-manager-plugin.deb \
&& dpkg -i /tmp/session-manager-plugin.deb \
&& rm -f /tmp/session-manager-plugin.deb \
&& session-manager-plugin --version
# Install ast-grep and yarn
RUN npm i @ast-grep/cli -g \
&& npm i yarn -g
# Install a newer Neovim than what Debian provides.
RUN mkdir -p /opt/nvim \
&& curl -fsSL "https://github.com/neovim/neovim/releases/latest/download/nvim-linux-$(uname -m | sed s/aarch64/arm64/).tar.gz" \
| tar -C /opt/nvim --strip-components=1 -xz
# Configure PHP, make memory_limit and upload_max_filesize match Pantheon
RUN cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini \
&& sed -i 's/memory_limit\s*=.*/memory_limit=2048M/g' /usr/local/etc/php/php.ini \
&& sed -i 's/;max_input_vars\s*=.*/max_input_vars=10000/g' /usr/local/etc/php/php.ini \
&& sed -i 's/post_max_size\s*=.*/post_max_size=100M/g' /usr/local/etc/php/php.ini \
&& sed -i 's/upload_max_filesize\s*=.*/upload_max_filesize=100M/g' /usr/local/etc/php/php.ini \
&& sed -i 's/variables_order\s*=.*/variables_order="EGPCS"/g' /usr/local/etc/php/php.ini
# Stop xdebug from spamming the console
RUN echo 'xdebug.log_level = 0' >> /usr/local/etc/php/conf.d/xdebug.ini
# Only use higher port for Apache, so that port forwarding is more consistent.
RUN sed -i 's/Listen\s*80$/# Listen 80/' /etc/apache2/ports.conf
# Enable Apache modules
RUN a2enmod expires headers rewrite
# Set umask for Apache to ensure group-writable files
RUN echo "umask 002" >> /etc/apache2/envvars
# Install terminus
RUN curl -fsSL https://github.com/pantheon-systems/terminus/releases/latest/download/terminus.phar --output /usr/local/bin/terminus \
&& chmod +x /usr/local/bin/terminus \
&& terminus self:plugin:install terminus-secrets-manager-plugin
# Install 1password-cli, see https://developer.1password.com/docs/cli/get-started/
RUN curl -sS https://downloads.1password.com/linux/keys/1password.asc \
| gpg --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/$(dpkg --print-architecture) stable main" \
| tee /etc/apt/sources.list.d/1password.list \
&& mkdir -p /etc/debsig/policies/AC2D62742012EA22/ \
&& curl -sS https://downloads.1password.com/linux/debian/debsig/1password.pol \
| tee /etc/debsig/policies/AC2D62742012EA22/1password.pol \
&& mkdir -p /usr/share/debsig/keyrings/AC2D62742012EA22 \
&& curl -sS https://downloads.1password.com/linux/keys/1password.asc \
| gpg --dearmor --output /usr/share/debsig/keyrings/AC2D62742012EA22/debsig.gpg \
&& apt update && apt install 1password-cli
# Install starship prompt
RUN curl -sS https://starship.rs/install.sh | sh -s -- --yes
# Install atuin
#
# # The recommended way to install atuin is to use cargo, but that takes *forever*:
# USER vscode
# RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# RUN PATH="$HOME/.cargo/bin:$PATH" cargo install atuin
#
# # So instead we download the latest precompiled binary for our cpu architecture:
# The releases/latest/download URL avoids api.github.com, whose unauthenticated
# rate limit on shared CI runners intermittently broke this step.
RUN curl -fsSL "https://github.com/atuinsh/atuin/releases/latest/download/atuin-$(uname -m)-unknown-linux-gnu.tar.gz" | tar zx --no-same-owner --wildcards --absolute-names --transform 's,[^/]*,/usr/local/bin,' '*/atuin'
# Prepare the .claude directory to work as a mounted volume that can been altered
# Works around a Docker named-volume issue:
# When Docker creates a brand-new named volume and mounts it into an empty path,
# it initializes that directory as root:root regardless of what user your container normally runs as.
RUN mkdir -p /home/vscode/.claude && chown vscode:vscode /home/vscode/.claude
# Our base image has an ancient version of gh cli in apt, so we download the latest version instead.
# gh's asset names include the version, so read it from the releases/latest redirect
# rather than api.github.com (rate-limited for unauthenticated CI runners).
RUN GH_VERSION=$(curl -fsSL -o /dev/null -w '%{url_effective}' https://github.com/cli/cli/releases/latest) \
&& GH_VERSION=${GH_VERSION##*/v} \
&& GH_ARCH=$(uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) \
&& curl -fsSL "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_${GH_ARCH}.tar.gz" | tar zx --no-same-owner --wildcards --absolute-names --transform 's,[^/]*,/usr/local,' '*/gh'
# Copy our scripts and template files
COPY local /usr/local/