Skip to content

Commit

Permalink
Directly output config to /opt
Browse files Browse the repository at this point in the history
  • Loading branch information
tsigouris007 committed Feb 9, 2024
1 parent d134d00 commit 1d93dd3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ RUN apt-get clean autoclean && apt-get autoremove --yes
# Apt update + package installations
RUN apt-get update && apt-get install -y gettext-base curl

# Copy CrowdStrike deb package
COPY deb/crowdstrike-cs-falconhoseclient_2.18.0_amd64.deb "${WORKDIR}/crowdstrike.deb"
RUN dpkg -i "${WORKDIR}/crowdstrike.deb"

# Prepare a simple user instead of root
RUN groupadd -r user && useradd -r -g user user
RUN mkdir -p /var/log/crowdstrike/falconhoseclient
RUN chown -R user:user /var/log/crowdstrike/falconhoseclient
RUN chmod -R 755 /var/log/crowdstrike/falconhoseclient
RUN chown -R user:user /opt/crowdstrike/etc

WORKDIR "${WORKDIR}"

# Copy entrypoint
COPY entrypoint.sh "${WORKDIR}"
RUN chmod +x "${WORKDIR}/entrypoint.sh"

# Copy CrowdStrike deb package
COPY deb/crowdstrike-cs-falconhoseclient_2.18.0_amd64.deb "${WORKDIR}/crowdstrike.deb"
RUN dpkg -i "${WORKDIR}/crowdstrike.deb"

# Link the binary executables to /usr/bin
RUN ln -s /opt/crowdstrike/bin/cs.falconhoseclient /usr/bin/cs.falconhoseclient
RUN ln -s "${WORKDIR}/entrypoint.sh" /usr/bin/falconhoseclient
Expand All @@ -53,4 +53,6 @@ RUN chown -R user:user "${WORKDIR}"
# Change to user
USER user

ENV PATH="${WORKDIR}:${PATH}"

ENTRYPOINT [ "falconhoseclient" ]
5 changes: 3 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

WORKDIR="/home/user"
CONFIGDIR="/opt/crowdstrike/etc"
CONFIG="cs.falconhoseclient.cfg"

# Read the .env file properties
Expand Down Expand Up @@ -30,6 +31,6 @@ fi
echo "API Base URL: $API_BASE_URL"

# Substitute things properly
export $(echo "CLIENT_ID=$CLIENT_ID CLIENT_SECRET=$CLIENT_SECRET API_BASE_URL=$API_BASE_URL") && envsubst < "${WORKDIR}/${CONFIG}.template" > "${WORKDIR}/${CONFIG}"
export $(echo "CLIENT_ID=$CLIENT_ID CLIENT_SECRET=$CLIENT_SECRET API_BASE_URL=$API_BASE_URL") && envsubst < "${WORKDIR}/${CONFIG}.template" > "${CONFIGDIR}/${CONFIG}"

cs.falconhoseclient -nodaemon -config="${WORKDIR}/${CONFIG}" 2>&1
cs.falconhoseclient -nodaemon -config="${CONFIGDIR}/${CONFIG}" 2>&1

0 comments on commit 1d93dd3

Please sign in to comment.