Построение docker container для тестов selenium
Собираю docker image для использования в gitlab-ci Что я уже написал:
FROM ubuntu:latest as ubuntu
FROM php:8.1-cli as php
FROM node:14.15.0-stretch AS node
FROM selenium/standalone-chrome:latest
COPY --from=ubuntu /bin /bin
COPY --from=php /app /app
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
COPY --from=node /usr/local/bin/node /usr/local/bin/node
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
# EXPOSE 4444
# EXPOSE 7900
LABEL miekrif uzvar-selenium
ENTRYPOINT ["/bin/bash"]
Чего я хотел добиться: У меня есть stage в .gitlab-ci.yml со след пунктами:
test-dev:
stage: test
image: miekrif/uzavr-selenium:latest
script:
- npm i
- npm run prod
- nohup /opt/bin/start-selenium-standalone.sh &
- npx mocha tests/js/screenshots-* --timeout 50000
- npx playwright test tests/js/pw_*
- php artisan test
Чего я хочу добиться: Данная джоба существует для тестирования кода, не смог додуматься как подругому завести selenium\standalone-chrome чтобы npx смог провести тесты ибо он ссылается на 127.0.0.1
Сейчас контейнер выдает ошибку:
/usr/bin/sh: /usr/bin/sh: cannot execute binary file
Ответы (1 шт):
Автор решения: Miekrif
→ Ссылка
Dockerfile:
FROM ubuntu:latest
FROM node:14.15.0-stretch AS node
RUN npm i libnpx
FROM selenium/standalone-chrome:latest as sel
USER root
#selenium copy
#COPY --from=sel /opt/bin/start-selenium-standalone.sh /opt/bin/start-selenium-standalone.sh
#COPY --from=sel /etc/supervisor/conf.d/ /etc/supervisor/conf.d/
#COPY --from=sel /opt/bin/generate_config /opt/bin/generate_config
#COPY --from=sel /opt/selenium/config.toml /opt/selenium/config.toml
#COPY --from=sel /opt/selenium/browser_name /opt/selenium/browser_name
#ENV SE_RELAX_CHECKS true
EXPOSE 4444
EXPOSE 7900
#Nodejs
#COPY --from=node / /
COPY --from=node /usr/local/lib/ /usr/local/lib/
COPY --from=node /usr/local/bin/ /usr/local/bin/
COPY --from=node /usr/local/bin/ /usr/local/bin/
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
LABEL miekrif uzvar-selenium
CMD ["bash"]
job
test-dev:
stage: test
image: miekrif/uzavr-selenium:latest
script:
- nohup /opt/bin/entry_point.sh &
- npx mocha tests/js/screenshots-* --timeout 50000
- npx playwright test tests/js/pw_*
- php artisan test