diff --git a/Dockerfile b/Dockerfile index 06caa16..d9a4cfb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,20 @@ # syntax=docker/dockerfile:1.4 +# Compile our webserver and Ansible launcher +FROM rockylinux:8.9 AS builder +RUN dnf install -y go +COPY *.go go.* . +RUN go build . + + +# Build the actual image FROM rockylinux:8.9 LABEL org.opencontainers.image.authors="Lucas Ritzdorf " # Define API base URLs +## TPM-manager webserver's port for POST requests +ARG TPM_PORT=27730 +ENV TPM_PORT=$TPM_PORT ## OPAAL server for auth token provisioning ENV OPAAL_URL=http://opaal:3333 ## SMD server for node inventory retrieval @@ -23,8 +34,11 @@ COPY ansible-smd-inventory/smd_inventory.py /usr/share/ansible/plugins/inventory COPY ansible/ ansible/ WORKDIR ansible -# Copy our helper script, which gets a token for smd and exec's Ansible -COPY ansible_shim.sh . +# Copy our webserver/launcher +COPY --from=builder TPM-manager . + +# Expose webserver's port for POST requests +EXPOSE $TPM_PORT -# TODO: This should eventually be some sort of daemon process -CMD ./ansible_shim.sh +# Run the webserver/launcher +CMD ./TPM-manager -batch-size 100 -interval 5m -playbook main.yaml -port $TPM_PORT diff --git a/ansible_shim.sh b/ansible_shim.sh deleted file mode 100755 index 03d82e1..0000000 --- a/ansible_shim.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env sh -set -e - -ACCESS_TOKEN="`curl $OPAAL_URL/token | jq -r '.access_token'`" -export ACCESS_TOKEN -exec ansible-playbook main.yaml