FROM 086679231553.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:python311

USER root

# Update packages and install packages required to install Chef Server
RUN apt-get -y update \
  && apt-get -y upgrade \
  && apt-get install -y wget net-tools ethtool iproute2 cron locales \
  && apt-get -y clean \
  && rm -rf /var/lib/apt/lists/*

# Download and install Chef Server
RUN wget https://packages.chef.io/files/stable/chef-server/15.9.27/ubuntu/18.04/chef-server-core_15.9.27-1_amd64.deb -O chef-server-core_15.9.27-1_amd64.deb
RUN dpkg -i chef-server-core_15.9.27-1_amd64.deb

# Chef Server relies on systemd, so we use docker-systemctl-replacement to mimic systemctl calls
ENV VIRTUAL_ENV /var/venv
RUN python3.11 -m venv ${VIRTUAL_ENV}
ENV PATH "$VIRTUAL_ENV/bin:$PATH"
RUN pip install docker-systemctl-replacement==1.5.8066 awscli
RUN ln -s /var/venv/bin/systemctl.py /usr/bin/systemctl

# Configure locale
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
    dpkg-reconfigure --frontend=noninteractive locales
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8

ENV CHEF_LICENSE accept

COPY chef-server.rb /usr/share/chef/chef-server.rb
COPY entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
