小编Gab*_*ujo的帖子

在docker镜像上使用npm global install时没有访问权限错误

我正在尝试使用全局安装的firebase-tools和angular-cli 构建一个docker镜像.我正在为两个版本的节点构建相同的图像:6.x(LTS硼)和v8.x(最新的alpine).在本地,两个图像都很好,但是当我尝试在docker hub中构建时,只有v6.x构建成功.使用v8.x,它将被困在undefined和nobody用户访问权限中.我已经在使用root用户(USER root),因为没有这个设置(或使用USER节点),两个图像都无法构建.

这是我的Dockerfile:

FROM node:latest

USER root

RUN npm install --quiet --no-progress -g @angular/cli@latest firebase-tools
RUN npm cache clean --force
Run Code Online (Sandbox Code Playgroud)

这是输出:

Step 4/5 : RUN npm install --quiet --no-progress -g @angular/cli@latest firebase-tools

 ---> Running in fce3da11b04e

 npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
 /usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/bin/firebase
 /usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng

> node-sass@4.5.3 install /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass
> node scripts/install.js

Unable to save binary /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/vendor/linux-x64-57 : { Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/vendor' …
Run Code Online (Sandbox Code Playgroud)

npm docker

16
推荐指数
4
解决办法
6206
查看次数

无法在docker容器内运行声纳扫描器:权限被拒绝

我正在尝试使用CI目的(bitbucket管道)构建自定义docker镜像.在构建并测试我的代码之后,我希望我可以使用sonarqube进行一些分析.

在我的自定义图像上,我尝试安装声纳扫描仪,因此当它在容器中时它将被执行.但是,在容器内(在bitbucket或我的本地机器上)它失败并出现此错误:

/sonar-scanner-2.8/bin/sonar-scanner: 108: exec: : Permission denied
Run Code Online (Sandbox Code Playgroud)

我已经尝试了许多不同的方法来设置扫描程序目录的权限和所有权,但没有任何工作.

更令人惊讶的是,即使使用闪存运行容器,--privileged=true我仍然会得到相同的错误.

我对Docker基础知识缺少什么?

这是我最后一个版本的Dockerfile:

# Pull base image.
FROM node:6

LABEL maintainer "Gabriel Araujo <contact@gbiel.com>"

ENV SONAR_SCANNER_VERSION 2.8
ENV SONAR_SCANNER_HOME /home/sonar-scanner-${SONAR_SCANNER_VERSION}
ENV SONAR_SCANNER_PACKAGE sonar-scanner-${SONAR_SCANNER_VERSION}.zip
ENV SONAR_RUNNER_HOME ${SONAR_SCANNER_HOME}
ENV PATH $PATH:${SONAR_SCANNER_HOME}/bin
ENV WORKDIR /home/workspace

# Define working directory.
WORKDIR ${WORKDIR}

# Install dependencies
RUN apt-get -yqq update && \
    apt-get -yqq --no-install-recommends install git bzip2 curl unzip && \
    npm install -g gulp bower && \
    npm cache clean && \ …
Run Code Online (Sandbox Code Playgroud)

sonar-runner docker sonarqube

6
推荐指数
1
解决办法
5673
查看次数

发布新版本的 SPA 时如何重新加载模板(html)?

目前,我在发布新版本的 SPA 时遇到了麻烦,因为 html 模板已被浏览器缓存。

我的 SPA 使用 Angular 1.5、ocLazyload 和 ui-router。我已经将 gulp 任务配置为使用缓存清除技术(使用gulp-rev),并且它运行得很好,至少对于脚本和 css 文件来说是这样。然而,当我们对 html 文件进行更改时,浏览器会继续加载旧版本。有时即使使用Ctrl+F5刷新页面也无法解决问题,并且一直显示旧版本的html。

此外,将浏览器配置为不缓存 html 文件是不可取的(特别是对于移动设备),因为 html 更改可能不会经常发生。

有没有什么好的解决方案可以解决这个问题,仅当有新版本时才获取 html 文件?

提前致谢!

html browser-cache angularjs oclazyload

5
推荐指数
1
解决办法
3555
查看次数

如何在角度组件中测试 ViewChild/ContentChild 属性?

我有一个用于正确显示验证错误的表单容器。我通过 ContentChild 装饰器访问表单控件并对其进行操作以构建验证消息。

我的问题是:如何正确地对这样的组件进行单元测试?

组件.ts

import { Component, ContentChild, Input, AfterContentInit } from '@angular/core';
import { FormControlName } from '@angular/forms';

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/map';

@Component({
  selector: 'app-form-group',
  templateUrl: './form-group.component.html',
  styleUrls: ['./form-group.component.scss'],
})
export class FormGroupComponent implements AfterContentInit {

  @Input()
  errorMessages: { [key: string]: string } = { };

  @ContentChild(FormControlName)
  control: FormControlName;

  message: Observable<string>;
  success: Observable<boolean>;
  error: Observable<boolean>;

  private buildErrorMessage(status): string {
    if (status === 'INVALID' && this.control.touched && this.control.dirty) {
      return Object.keys(this.control.errors)
        .map(errorKey => …
Run Code Online (Sandbox Code Playgroud)

unit-testing typescript angular

3
推荐指数
1
解决办法
5325
查看次数

在 Openshift 上以非 root 用户身份运行 nginx 并侦听端口 80

我已经连续几天尝试配置一个在 Openshift 上运行的 nginx 容器,但直到现在还没有让它工作。

我已阅读有关出于安全原因使用非 root 用户的信息。但是,无论是 root 用户还是非 root 用户,openshift 都不允许我在端口 80 的容器中创建绑定。

2017/06/22 21:18:57 [emerg] 1#1: bind() to 0.0.0.0:80 failed (13: Permission denied)
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
Run Code Online (Sandbox Code Playgroud)

在我的本地机器上,我可以成功绑定到容器上的更高端口(例如 8081),然后在主机 ( docker run --rm -d -p 9000:8081 mynginx) 中创建一个用于访问的映射。通过这种方式,我可以成功访问主机地址上的网站localhost:9000,但我不知道如何在 openshit 上实现类似的功能。

我希望我可以使用非 root 用户和 nginx 在更高的端口 (8081) 上侦听来部署我的映像,同时 openshift 将服务器端口 80 的所有传入流量转发到容器 (nginx) 的端口 8081。我目前的设置如下:

Dockerfile:

FROM nginx:alpine

COPY nginx.conf /etc/nginx/nginx.conf
COPY dist /usr/share/nginx/html

RUN chmod …
Run Code Online (Sandbox Code Playgroud)

security nginx openshift docker openshift-origin

1
推荐指数
1
解决办法
6947
查看次数