use*_*695 4 ubuntu gitlab meteor docker gitlab-ci
我正在创建一个基于 ubuntu 的自定义 docker 镜像 ( testing:latest)。我想为流星应用程序运行一些单元测试。
FROM ubuntu:16.04
RUN apt-get update -y && \
apt-get install -yqq --no-install-recommends apt-transport-https ca-certificates curl nodejs-legacy && \
apt-get clean && apt-get autoclean && apt-get autoremove && \
curl https://install.meteor.com/ | sh && \
meteor npm install eslint eslint-plugin-react && \
apt-get remove -y apt-transport-https ca-certificates curl && \
rm -rf /var/lib/apt/lists/*
Run Code Online (Sandbox Code Playgroud)
我正在使用 gitlab CI 使用docker runner。所以我的 yml 文件看起来像
stages:
- test
lint:
image: testing:latest
stage: test
script:
- /node_modules/.bin/eslint --ext .js --ext .jsx .
except:
- master
unit:
image: testing:latest
stage: test
script:
- whoami
- meteor test --driver-package=practicalmeteor:mocha-console-runner
except:
- master
Run Code Online (Sandbox Code Playgroud)
运行whoami显示当前用户是root. 因此,流星测试没有运行,因为它不应该与root
You are attempting to run Meteor as the 'root' superuser. If you are
developing, this is almost certainly *not* what you want to do and will likely
result in incorrect file permissions. However, if you are running this command
in a build process (CI, etc.), or you are absolutely sure you know what you are
doing, set the METEOR_ALLOW_SUPERUSER environment variable or pass
--allow-superuser to proceed.
Even with METEOR_ALLOW_SUPERUSER or --allow-superuser, permissions in your app
directory will be incorrect if you ever attempt to perform any Meteor tasks as
a normal user. If you need to fix your permissions, run the following command
from the root of your project:
sudo chown -Rh <username> .meteor/local
Run Code Online (Sandbox Code Playgroud)
我如何使用其他用户?我必须在 dockerfile 中执行此操作吗?或者我必须在 yml 文件中添加一些命令?
RUN useradd <username>然后您可以按照正常的 Ubuntu 方式执行USER <username>并运行该任务。
该指令设置运行映像时要使用
USER的用户名或 UIDRUN,CMD以及.ENTRYPOINTDockerfile
您还可以看看这个SO答案:Switching users inside Docker image to a non-root user
| 归档时间: |
|
| 查看次数: |
3020 次 |
| 最近记录: |