Skip to content

Commit

Permalink
Merge pull request #4592 from telefonicaid/hardening/impreove-secrets…
Browse files Browse the repository at this point in the history
…-management

FIX improve Docker building process
  • Loading branch information
mapedraza authored Jul 4, 2024
2 parents 8c24790 + 6b45bcd commit f0e7cc5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publishimage-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TEF_TOKEN }}

- name: Build Docker image
run: docker build -t telefonicaiot/fiware-orion:latest --build-arg GIT_REV_ORION=master --build-arg REPO_ACCESS_TOKEN=${{ secrets.REPO_ACCESS_TOKEN }} --no-cache -f docker/Dockerfile .
run: docker build -t telefonicaiot/fiware-orion:latest --build-arg GIT_REV_ORION=master --secret id=repo_token,env=${{ secrets.REPO_ACCESS_TOKEN }} --no-cache -f docker/Dockerfile .

- name: Push Docker image
run: docker push telefonicaiot/fiware-orion:latest
2 changes: 1 addition & 1 deletion .github/workflows/publishimage-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Build Docker image
run: docker build -t telefonicaiot/fiware-orion:${{ env.VERSION }} --build-arg GIT_REV_ORION=${{ env.VERSION }} --build-arg REPO_ACCESS_TOKEN=${{ secrets.REPO_ACCESS_TOKEN }} --no-cache -f docker/Dockerfile .
run: docker build -t telefonicaiot/fiware-orion:${{ env.VERSION }} --build-arg GIT_REV_ORION=${{ env.VERSION }} --secret id=repo_token,env=${{ secrets.REPO_ACCESS_TOKEN }} --no-cache -f docker/Dockerfile .

- name: Push Docker image
run: docker push telefonicaiot/fiware-orion:${{ env.VERSION }}
6 changes: 2 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,17 @@ ARG GITHUB_REPOSITORY=fiware-orion
ARG GIT_NAME
ARG GIT_REV_ORION
ARG CLEAN_DEV_TOOLS
ARG REPO_ACCESS_TOKEN

ENV ORION_USER ${ORION_USER:-orion}
ENV GIT_NAME ${GIT_NAME:-telefonicaid}
ENV GIT_REV_ORION ${GIT_REV_ORION:-master}
ENV CLEAN_DEV_TOOLS ${CLEAN_DEV_TOOLS:-1}
ENV REPO_ACCESS_TOKEN ${REPO_ACCESS_TOKEN:-""}

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

WORKDIR /opt

RUN \
RUN --mount=type=secret,id=repo_token,dst=/run/secrets/repo_token \
# Install security updates
apt-get -y update && \
apt-get -y upgrade && \
Expand Down Expand Up @@ -104,7 +102,7 @@ RUN \
git clone https://github.com/${GIT_NAME}/fiware-orion && \
cd fiware-orion && \
git checkout ${GIT_REV_ORION} && \
bash get_cjexl.sh 0.3.0 ${REPO_ACCESS_TOKEN} && \
bash get_cjexl.sh 0.3.0 $(cat /run/secrets/repo_token) && \
make && \
make install && \
# reduce size of installed binaries
Expand Down
6 changes: 2 additions & 4 deletions docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,17 @@ ARG GITHUB_REPOSITORY=fiware-orion
ARG GIT_NAME
ARG GIT_REV_ORION
ARG CLEAN_DEV_TOOLS
ARG REPO_ACCESS_TOKEN

ENV ORION_USER ${ORION_USER:-orion}
ENV GIT_NAME ${GIT_NAME:-telefonicaid}
ENV GIT_REV_ORION ${GIT_REV_ORION:-master}
ENV CLEAN_DEV_TOOLS ${CLEAN_DEV_TOOLS:-1}
ENV REPO_ACCESS_TOKEN ${REPO_ACCESS_TOKEN:-""}

SHELL ["/bin/ash", "-o", "pipefail", "-c"]

WORKDIR /opt

RUN \
RUN --mount=type=secret,id=repo_token,dst=/run/secrets/repo_token \
# Install dependencies
apk add --no-cache \
curl \
Expand Down Expand Up @@ -110,7 +108,7 @@ RUN \
git clone https://github.com/${GIT_NAME}/fiware-orion && \
cd fiware-orion && \
git checkout ${GIT_REV_ORION} && \
bash get_cjexl.sh 0.3.0 ${REPO_ACCESS_TOKEN} && \
bash get_cjexl.sh 0.3.0 $(cat /run/secrets/repo_token) && \
# patch bash and mktemp statement in build script, as in alpine is slightly different
sed -i 's/mktemp \/tmp\/compileInfo.h.XXXX/mktemp/g' scripts/build/compileInfo.sh && \
sed -i 's/bash/ash/g' scripts/build/compileInfo.sh && \
Expand Down

0 comments on commit f0e7cc5

Please sign in to comment.