|
| 1 | +ARG BASE_REGISTRY=registry1.dso.mil |
| 2 | +ARG BASE_IMAGE=ironbank/redhat/ubi/ubi8-minimal |
| 3 | +ARG BASE_TAG=8.7 |
| 4 | + |
| 5 | +FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} |
| 6 | + |
| 7 | +SHELL ["/bin/bash", "-c"] |
| 8 | + |
| 9 | +ENV LANG=en_US.UTF-8 |
| 10 | + |
| 11 | +RUN microdnf update --assumeyes && \ |
| 12 | + microdnf install --assumeyes \ |
| 13 | + ca-certificates \ |
| 14 | + git \ |
| 15 | + gzip \ |
| 16 | + shadow-utils \ |
| 17 | + tar \ |
| 18 | + unzip && \ |
| 19 | + microdnf clean all |
| 20 | + |
| 21 | +# Configure the cryptography policy manually. These policies likely |
| 22 | +# have no impact, since Go doesn't link against these libraries. |
| 23 | +# |
| 24 | +# Normally, one uses the update-crypto-policies script to create these |
| 25 | +# links, which is included in the crypto-policies-scripts package, but |
| 26 | +# that pulls in Python, so we create the links manually here. This |
| 27 | +# list of links comes from running strace on the update-crypto-policies |
| 28 | +# script (strace update-crypto-policies --set FIPS) in Fedora, since |
| 29 | +# RHEL and UBI do not provide an strace package by default. |
| 30 | +RUN echo "FIPS" >/etc/crypto-policies/config && \ |
| 31 | + cp --force /usr/share/crypto-policies/policies/FIPS.pol /etc/crypto-policies/state/CURRENT.pol && \ |
| 32 | + echo "FIPS" >/etc/crypto-policies/state/current && \ |
| 33 | + ln --symbolic --force /usr/share/crypto-policies/FIPS/bind.txt /etc/crypto-policies/back-ends/bind.config && \ |
| 34 | + ln --symbolic --force /usr/share/crypto-policies/FIPS/gnutls.txt /etc/crypto-policies/back-ends/gnutls.config && \ |
| 35 | + ln --symbolic --force /usr/share/crypto-policies/FIPS/java.txt /etc/crypto-policies/back-ends/java.config && \ |
| 36 | + ln --symbolic --force /usr/share/crypto-policies/FIPS/krb5.txt /etc/crypto-policies/back-ends/krb5.config && \ |
| 37 | + ln --symbolic --force /usr/share/crypto-policies/FIPS/libreswan.txt /etc/crypto-policies/back-ends/libreswan.config && \ |
| 38 | + ln --symbolic --force /usr/share/crypto-policies/FIPS/libssh.txt /etc/crypto-policies/back-ends/libssh.config && \ |
| 39 | + ln --symbolic --force /usr/share/crypto-policies/FIPS/nss.txt /etc/crypto-policies/back-ends/nss.config && \ |
| 40 | + ln --symbolic --force /usr/share/crypto-policies/FIPS/openssh.txt /etc/crypto-policies/back-ends/openssh.config && \ |
| 41 | + ln --symbolic --force /usr/share/crypto-policies/FIPS/opensshserver.txt /etc/crypto-policies/back-ends/opensshserver.config && \ |
| 42 | + ln --symbolic --force /usr/share/crypto-policies/FIPS/openssl.txt /etc/crypto-policies/back-ends/openssl.config && \ |
| 43 | + ln --symbolic --force /usr/share/crypto-policies/FIPS/opensslcnf.txt /etc/crypto-policies/back-ends/opensslcnf.config |
| 44 | + |
| 45 | +# Copy and extract Coder binary from tar file. We have to put this in /opt to |
| 46 | +# match the Dockerfile. |
| 47 | +ARG CODER_BIN=/opt/coder |
| 48 | +ARG CODER_BIN_TAR_GZ=coder.tar.gz |
| 49 | +COPY "$CODER_BIN_TAR_GZ" /tmp/coder.tar.gz |
| 50 | +RUN mkdir -p /opt && \ |
| 51 | + tar -xzvf /tmp/coder.tar.gz --directory /opt --strip-components=1 ./coder && \ |
| 52 | + rm /tmp/coder.tar.gz |
| 53 | +ENV PATH="/opt:${PATH}" |
| 54 | + |
| 55 | +# Copy and extract Terraform binary from zip file. |
| 56 | +ARG TERRAFORM_BIN_DIR=/opt/terraform |
| 57 | +ARG TERRAFORM_BIN_ZIP=terraform.zip |
| 58 | +COPY "$TERRAFORM_BIN_ZIP" /tmp/terraform.zip |
| 59 | +RUN mkdir -p "$TERRAFORM_BIN_DIR" && \ |
| 60 | + unzip /tmp/terraform.zip -d "$TERRAFORM_BIN_DIR" && \ |
| 61 | + rm /tmp/terraform.zip |
| 62 | +ENV PATH="${TERRAFORM_BIN_DIR}:${PATH}" |
| 63 | + |
| 64 | +# Install the Coder Terraform provider to a well-known location. |
| 65 | +ARG TERRAFORM_PLUGINS_DIR=/opt/terraform/plugins |
| 66 | +ARG TERRAFORM_CODER_PROVIDER_VERSION |
| 67 | +ARG TERRAFORM_CODER_PROVIDER_ZIP=terraform-provider-coder.zip |
| 68 | +COPY "$TERRAFORM_CODER_PROVIDER_ZIP" "${TERRAFORM_PLUGINS_DIR}/registry.terraform.io/coder/coder/terraform-provider-coder_${TERRAFORM_CODER_PROVIDER_VERSION}_linux_amd64.zip" |
| 69 | + |
| 70 | +# Configure Terraform to use plugins from this dir. |
| 71 | +COPY terraform-filesystem-mirror.tfrc /opt/terraform/config.tfrc |
| 72 | +ENV TF_CLI_CONFIG_FILE=/opt/terraform/config.tfrc |
| 73 | + |
| 74 | +# Uninstall the build dependencies. |
| 75 | +RUN microdnf remove --assumeyes \ |
| 76 | + tar \ |
| 77 | + unzip && \ |
| 78 | + microdnf clean all |
| 79 | + |
| 80 | +# Transfer ownership of the binaries to the 'coder' user. |
| 81 | +RUN useradd coder \ |
| 82 | + --create-home \ |
| 83 | + --shell=/bin/bash \ |
| 84 | + --uid=1000 \ |
| 85 | + --user-group && \ |
| 86 | + chown --recursive --quiet coder:coder "$CODER_BIN" && \ |
| 87 | + chown --recursive --quiet coder:coder "$TERRAFORM_BIN_DIR" && \ |
| 88 | + chown --recursive --quiet coder:coder "$TERRAFORM_PLUGINS_DIR" && \ |
| 89 | + chmod 0755 /home/coder |
| 90 | + |
| 91 | +USER 1000 |
| 92 | +ENV HOME /home/coder |
| 93 | +ENV USER=coder |
| 94 | + |
| 95 | +ENTRYPOINT [ "/opt/coder", "server" ] |
0 commit comments