Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker test #3159

Merged
merged 29 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci-cd.yml
DonnieBLT marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,34 @@ jobs:
- run: poetry run python manage.py collectstatic --noinput
- name: Run tests
run: poetry run xvfb-run --auto-servernum python manage.py test -v 3 --failfast

docker-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker
run: |
docker --version
# Install docker-compose
curl -sSL https://github.com/docker/compose/releases/download/v2.17.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version

- name: Build Docker image
run: |
docker build -t my-app .

- name: Run Docker container
run: |
docker run -d --name my-container my-app

- name: Install dependencies inside Docker container to test the env
run: |
docker exec my-container poetry install --no-dev --no-interaction

- name: Clean up
run: |
docker stop my-container
docker rm my-container
22 changes: 21 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ RUN apt-get update && \
dos2unix && \
rm -rf /var/lib/apt/lists/*

# # Install Chrome WebDriver
# RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
# mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION && \
# curl -sS -o /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \
# unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION && \
# rm /tmp/chromedriver_linux64.zip && \
# chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver && \
# ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver

# Install Google Chrome
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
apt-get -yqq update && \
apt-get -yqq install google-chrome-stable && \
rm -rf /var/lib/apt/lists/*

RUN ln -s /usr/bin/google-chrome-stable /usr/local/bin/google-chrome

# Install Poetry and dependencies
RUN pip install poetry
RUN poetry config virtualenvs.create false
Expand Down Expand Up @@ -40,7 +58,9 @@ RUN apt-get update && \
COPY . /blt

# Convert line endings and set permissions
RUN dos2unix .env Dockerfile docker-compose.yml entrypoint.sh ./blt/settings.py
RUN dos2unix Dockerfile docker-compose.yml entrypoint.sh ./blt/settings.py
# Check if .env exists and run dos2unix on it, otherwise skip
RUN if [ -f /blt/.env ]; then dos2unix /blt/.env; fi
RUN chmod +x /blt/entrypoint.sh

ENTRYPOINT ["/blt/entrypoint.sh"]
Expand Down
Loading