Skip to content

Commit

Permalink
Merge pull request #37 from elisa-tech/document-work-item
Browse files Browse the repository at this point in the history
Supporting a general purpose Document work item
  • Loading branch information
pellecchialuigi authored Sep 9, 2024
2 parents 8f42284 + 4b43193 commit 6bfd612
Show file tree
Hide file tree
Showing 28 changed files with 4,596 additions and 111 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: ci

on:
push:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Print current branch
run: echo "${BRANCH_NAME}"
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Api
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
uses: docker/build-push-action@v6
with:
build-args: |
ADMIN_PASSWORD=admin
API_PORT=5000
context: .
file: Dockerfile-api
push: false
tags: basil-api_${{ env.BRANCH_NAME }}
outputs: type=docker,dest=/tmp/basil-api.tar
- name: Build App
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
uses: docker/build-push-action@v6
with:
build-args: |
API_ENDPOINT=http://localhost:5000
context: .
file: Dockerfile-app
push: false
tags: basil-app_${{ env.BRANCH_NAME }}
outputs: type=docker,dest=/tmp/basil-app.tar
- name: Upload basil-api artifact
uses: actions/upload-artifact@v4
with:
name: basil-api
path: /tmp/basil-api.tar
- name: Upload basil-app artifact
uses: actions/upload-artifact@v4
with:
name: basil-app
path: /tmp/basil-app.tar
test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download basil-api artifacts
uses: actions/download-artifact@v4
with:
name: basil-api
path: /tmp
- name: Download basil-app artifacts
uses: actions/download-artifact@v4
with:
name: basil-app
path: /tmp
- name: Load images
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
docker load --input /tmp/basil-api.tar
docker load --input /tmp/basil-app.tar
docker image ls -a
docker run -d --privileged --network=host basil-api_${{ env.BRANCH_NAME }}
docker run -d --network=host basil-app_${{ env.BRANCH_NAME }}
sleep 60
docker ps
echo "Test Api is running"
curl -vf http://localhost:5000/version
echo "Test App is running"
curl -vf http://localhost:9000
10 changes: 8 additions & 2 deletions Dockerfile-api
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ FROM registry.fedoraproject.org/fedora:39
USER root
RUN mkdir BASIL-API
WORKDIR /BASIL-API
COPY . /BASIL-API
COPY api/ /BASIL-API/api
COPY db/ /BASIL-API/db
COPY misc/ /BASIL-API/misc
COPY requirements.txt pyproject.toml /BASIL-API/
RUN dnf install -y curl git patch python3 python3-pip podman rsync && \
pip3 install --no-cache-dir -r requirements.txt

Expand All @@ -15,14 +18,17 @@ ENV BASIL_ADMIN_PASSWORD=${ADMIN_PASSWORD} BASIL_API_PORT=${API_PORT}

# Init the database and
# Write permission to db
RUN cd db/models && \
RUN mkdir -p /var/tmp && cd /BASIL-API/db/models && \
python3 init_db.py && \
chmod a+rw /BASIL-API/db

# Apply patches
RUN patch -u /usr/local/lib/python3.12/site-packages/tmt/steps/provision/podman.py < /BASIL-API/misc/tmt_provision_podman.patch

# Remove BASIL ADMIN PASSWORD from the environment
ENV BASIL_ADMIN_PASSWORD=

Check warning on line 29 in Dockerfile-api

View workflow job for this annotation

GitHub Actions / build

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "BASIL_ADMIN_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 29 in Dockerfile-api

View workflow job for this annotation

GitHub Actions / build

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "BASIL_ADMIN_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

EXPOSE ${BASIL_API_PORT}
CMD echo "BASIL_API_PORT: ${BASIL_API_PORT}" && cd api && \

Check warning on line 32 in Dockerfile-api

View workflow job for this annotation

GitHub Actions / build

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/

Check warning on line 32 in Dockerfile-api

View workflow job for this annotation

GitHub Actions / build

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
gunicorn --access-logfile /var/tmp/tc-gunicorn-access.log \
--error-logfile /var/tmp/tc-gunicorn-error.log \
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile-app
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN mkdir BASIL-APP
COPY . /BASIL-APP
WORKDIR /BASIL-APP/app
# Set the public ip
ARG API_ENDPOINT=localhost:5000
ARG API_ENDPOINT=http://localhost:5000
ARG APP_PORT=9000
RUN sed -i "s#http://localhost:5000#${API_ENDPOINT}#g" src/app/Constants/constants.tsx && \
sed -i "s#--port 9000#--port ${APP_PORT}#g" package.json && \
Expand All @@ -17,4 +17,5 @@ RUN npm run build
# RUN sed -i "s/src=\"\//src=\"/g" dist/index.html
# RUN sed -i "s/href=\"\//href=\"/g" dist/index.html

EXPOSE ${APP_PORT}
CMD ["npm", "run", "start"]
Loading

0 comments on commit 6bfd612

Please sign in to comment.