adding docker folder

This commit is contained in:
t1m0t 2022-02-03 09:26:01 +01:00
parent 4135fabb8d
commit 74cc2eee81
4 changed files with 80 additions and 0 deletions

View file

@ -0,0 +1,9 @@
FROM rust:1.58-buster
RUN apt update
RUN apt install -y libglib2.0-dev libgtk-3-dev libsoup2.4-dev libappindicator3-dev libwebkit2gtk-4.0-dev firefox-esr
RUN cargo install cargo-make --debug
RUN cargo install cargo-cache && cargo cache -a
CMD ["echo","\"base image built\""]

8
docker/Dockerfile_test Normal file
View file

@ -0,0 +1,8 @@
FROM dioxus-base-test-image
RUN mkdir run_test
COPY tmp /run_test
WORKDIR /run_test
RUN cargo make tests
CMD ["exit"]

27
docker/README.md Normal file
View file

@ -0,0 +1,27 @@
# Why this?
This part is used to test whole package before pushing it
# How to use it?
Just run in the folder:
`bash run_local_tests.sh`. If nothing fails, then you can push your code to the repo.
or run:
`bash run_local_tests.sh --with-full-docker-cleanup`
for cleaning up images as well
# How is it composed of?
1. `Dockerfile_pre_test` will build the base image for the tests to be run into
2. `Dockerfile_test` will run the actual tests based on 1.
3. `run_local_tests.sh` to wrap this up
# Warning
The task requires some amount of CPU work and disk space (5GB per tests). Some clean up is included in the script.
# Requirements
* [docker](https://docs.docker.com/engine/install/)
* bash
* rsync

36
docker/run_local_tests.sh Normal file
View file

@ -0,0 +1,36 @@
set -eux
echo "Test script started"
function run_script {
if [[ -d tmp ]]
then
rm -rf tmp
mkdir tmp
else
mkdir tmp
fi
# copy files first
rsync -a --progress ../ tmp --exclude target --exclude docker
# build base image
docker build -f Dockerfile_pre_test -t dioxus-base-test-image .
# run test
docker build -f Dockerfile_test -t dioxus-test-image .
# clean up
rm -rf tmp
if [ $1 = "--with-full-docker-cleanup" ]
then
docker image rm dioxus-base-test-image
docker image rm dioxus-test-image
docker system prune -a --force
fi
}
run_script || echo "Error occured.. cleaning a bit." &&
docker system prune -a --force && \
rm -rf tmp;
echo "Script finished to execute"