Slackbot
01/24/2024, 1:14 PMBartosz Sobieraj
01/24/2024, 1:15 PMARG ATLANTIS_BASE_VERSION=2023.03.30
FROM <http://ghcr.io/runatlantis/atlantis-base:${ATLANTIS_BASE_VERSION}|ghcr.io/runatlantis/atlantis-base:${ATLANTIS_BASE_VERSION}> AS base
# Default tool versions installed in that image
ARG ATLANTIS_VERSION=v0.26.0
ARG ASDF_VERSION=v0.14.0
ARG TF_VERSION=1.5.2
ARG TG_VERSION=0.48.0
ARG TG_ATLANTIS_VERSION=1.16.0
ARG INFRACOST_VERSION=v0.10.32
ARG TFLINT_VERSION=0.50.2
ARG SOPS_VERSION=v3.7.3
RUN set -ex && \
apk update && \
apk add bash py3-pip curl && \
apk add --virtual=build gcc libffi-dev musl-dev openssl-dev python3-dev cargo make curl unzip aws-cli
# Download and install Infracost
RUN curl -LOs <https://github.com/infracost/infracost/releases/download/${INFRACOST_VERSION}/infracost-linux-amd64.tar.gz> && \
tar xzf infracost-linux-amd64.tar.gz && \
mv infracost-linux-amd64 /usr/bin/infracost && \
chmod a+x /usr/bin/infracost && \
rm -rf infracost-linux-amd64*
# Download and install Atlantis
RUN curl -LOs <https://github.com/runatlantis/atlantis/releases/download/${ATLANTIS_VERSION}/atlantis_linux_amd64.zip> && \
unzip atlantis_linux_amd64.zip -d /usr/bin && \
chmod a+x /usr/bin/atlantis && \
rm atlantis_linux_amd64.zip
# Download and install terragrunt-atlantis-config
RUN curl -LOs <https://github.com/transcend-io/terragrunt-atlantis-config/releases/download/v${TG_ATLANTIS_VERSION}/terragrunt-atlantis-config_${TG_ATLANTIS_VERSION}_linux_amd64.tar.gz> && \
tar xzf terragrunt-atlantis-config_${TG_ATLANTIS_VERSION}_linux_amd64.tar.gz && \
mv terragrunt-atlantis-config_${TG_ATLANTIS_VERSION}_linux_amd64/terragrunt-atlantis-config_${TG_ATLANTIS_VERSION}_linux_amd64 /usr/bin/terragrunt-atlantis-config && \
chmod a+x /usr/bin/terragrunt-atlantis-config && \
rm -rf terragrunt-atlantis-config_${TG_ATLANTIS_VERSION}_linux_amd64*
# Download and install SOPS
RUN curl -LOs <https://github.com/mozilla/sops/releases/download/${SOPS_VERSION}/sops-${SOPS_VERSION}.linux> && \
mv sops-${SOPS_VERSION}.linux /usr/bin/sops && \
chmod a+x /usr/bin/sops && \
rm -rf sops-${SOPS_VERSION}.linux
# Download and install asdf, create .profile and source asdf inside
RUN gosu atlantis bash -l -c " \
git clone --quiet <https://github.com/asdf-vm/asdf.git> /home/atlantis/.asdf --branch ${ASDF_VERSION} && \
echo '. /home/atlantis/.asdf/asdf.sh' >> /home/atlantis/.profile && \
chown atlantis.atlantis /home/atlantis/.profile && \
chmod u+rw /home/atlantis/.profile"
# Install all needed plugins
RUN gosu atlantis bash -l -c " \
asdf plugin-add terragrunt && \
asdf plugin-add terraform && \
asdf plugin-add tflint"
# Install default versions and define them globally
RUN gosu atlantis bash -l -c " \
cd /home/atlantis/ && \
asdf install terraform ${TF_VERSION} && \
asdf install terragrunt ${TG_VERSION} && \
asdf install tflint ${TFLINT_VERSION} && \
asdf global terraform ${TF_VERSION} && \
asdf global terragrunt ${TG_VERSION} && \
asdf global tflint ${TFLINT_VERSION}"
# Additional cleanup
RUN rm -rf /tmp/*
# Set atlantis login shell to bash
RUN sed -i s#atlantis:/sbin/nologin#atlantis:/bin/bash#g /etc/passwd
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod a+x /usr/local/bin/docker-entrypoint.sh
USER atlantis
# Add GitHub to known keys file for safe SSH connections
RUN mkdir -p /home/atlantis/.ssh && \
chmod 0700 /home/atlantis/.ssh && \
touch /home/atlantis/.ssh/known_hosts && \
chmod 0600 /home/atlantis/.ssh/known_hosts && \
ssh-keyscan -H <http://github.com|github.com> >> /home/atlantis/.ssh/known_hosts \
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["server"]Bartosz Sobieraj
01/24/2024, 1:15 PM#!/usr/bin/dumb-init /bin/sh
set -e
# If the user is trying to run atlantis directly with some arguments, then
# pass them to atlantis.
if [ "${1:0:1}" = '-' ]; then
set -- atlantis "@"
fi
# If the user is running an atlantis subcommand (ex. server) then we want to prepend
# atlantis as the first arg to exec. To detect if they're running a subcommand
# we take the potential subcommand and run it through atlantis help {subcommand}.
# If the output contains "atlantis subcommand" then we know it's a subcommand
# since the help output contains that string. For anything else (ex. sh)
# it won't contain that string.
# NOTE: We use grep instead of the exit code since help always returns 0.
if atlantis help "$1" 2>&1 | grep -q "atlantis $1"; then
# We can't use the return code to check for the existence of a subcommand, so
# we have to use grep to look for a pattern in the help output.
set -- bash --login -c "atlantis $@"
fi
# If the current uid running does not have a user create one in /etc/passwd
if ! whoami &> /dev/null; then
if [ -w /etc/passwd ]; then
echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:/home/atlantis:/sbin/bash" >> /etc/passwd
fi
fi
# If we're running as root and we're trying to execute atlantis then we use
# gosu to step down from root and run as the atlantis user.
if [[ $(id -u) == 0 ]] && [[ "$1" = 'atlantis' ]]; then
# If requested, set the capability to bind to privileged ports before
# we drop to the non-root user.
if [ ! -z ${ATLANTIS_ALLOW_PRIVILEGED_PORTS+x} ]; then
setcap "cap_net_bind_service=+ep" /bin/atlantis
fi
set -- gosu atlantis "$@"
fi
exec "$@"Bartosz Sobieraj
01/24/2024, 1:25 PMFelippe Bueno
01/24/2024, 5:12 PMserver
You are replacing the original entrypoint of the dockerfile and keeping the cmd (server).
Maybe the cmd should be ["atlantis", "server"]Felippe Bueno
01/24/2024, 5:12 PMatlantis you must specify the full pathBartosz Sobieraj
01/24/2024, 7:05 PM