我正在为我正在工作的公司的开发人员询问我与Docker做一些不同的事情然后我也被使用了.目标是拥有2个具有以下职责的容器:
容器A:将构建前端反应应用程序并将包放入名为的目录的节点容器app/dist/.完成后,容器将停止运行.
容器B:一个高山的nginx容器,它将从中提供静态文件/usr/share/nginx/html/app.
其中已建成的容器中的文件将使用体积将挂载提供给容器B <Container A>/app/dist来<Container B>/usr/share/nginx/html/app.
请注意,公共可访问端口和容器调用的nginx容器之间有一个HAProxy层app.
上面的任务是使用docker compose文件编排的,如下所示:
version: '2'
volumes:
webapp_build_volume: {}
services:
webapp_build:
build:
context: .
dockerfile: 'config/nginx/dockerfile-builder'
volumes:
- webapp_build_volume:/app/dist
- webapp_static_volume:/app/src/app/static
app:
build:
context: 'config/haproxy'
dockerfile: 'dockerfile-app-haproxy'
links:
- web
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- '80:80'
- '1936:1936'
web:
build:
context: .
dockerfile: 'config/nginx/dockerfile-web'
environment:
- EXCLUDE_PORTS=443
- VIRTUAL_HOST=*
depends_on:
- webapp_build
volumes:
- webapp_build_volume:/usr/share/nginx/html/app
Run Code Online (Sandbox Code Playgroud)
这仅在第一次构建docker compose文件时才有效.创建卷后,卷中的文件不再更新.我已经读过,命名卷在建立之后无法更新,但我无法确认.我找到了涉及运行的工作,docker-compose rm --force && docker volume webapp_build rm …
如果我有一个类似于此的模型:
class Dealer(models.Model):
name = models.CharField(max_length=10)
other_name = models.CharField(max_length=10, blank=True, null=True)
... etc.
Run Code Online (Sandbox Code Playgroud)
如果我想创建一个可以登录管理站点但只能编辑此模型的用户,我该怎么做呢?
我环顾四周,无法成功地让它发挥作用.我也研究了监护人这样的包裹,但没有成功.我在这里错过了什么?
谢谢!
我对使用@myDecorator语法的能力感到非常兴奋(使用babel).我试图装饰一个生命周期函数,具体来说componentWillMount,检查装饰器中的组件props和context.但是,我似乎无法访问props或context.我不确定这是否是一种反模式,或者我是否只是出错了.
小例子:
// TestComponent.jsx
import checkProps from 'checkProps.js';
class TestComponent extends React.Component {
@checkProps
componentWillMount() {
// Do something.
}
render() {
return <div>My Component</div>
}
}
Run Code Online (Sandbox Code Playgroud)
和
// checkProps.js
export function checkProps(target) {
console.log(target.props);
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过装饰器和检查的箭头函数this,但我不认为装饰器会以这种方式组合.
我也尝试让我的装饰器成为工厂并传入this.props,this.context但this在装饰组件生命周期功能时未定义.
我已经设置了我的按钮:
CGRect button1Frame = CGRectMake(200, 200, 100, 100);
self.button1 = [[UIButton alloc] initWithFrame:button1Frame];
[self.button1 addTarget:self action:@selector(goToController1:)
forControlEvents:UIControlEventTouchDown];
self.button1.userInteractionEnabled = YES;
self.button1.opaque = YES;
self.button1.backgroundColor = [UIColor redColor];
[self.button1 setTitle:@"B1" forState:UIControlStateNormal];
[self.view addSubview:self.button1];
Run Code Online (Sandbox Code Playgroud)
与我的发件人:
- (void) goToController1:(id)sender {
NSLog(@"Pressed");
}
Run Code Online (Sandbox Code Playgroud)
我的视图控制器已正确初始化.什么会导致我的按钮不显示?我检查过以确保所有内容都被正确调用.
find / \ -newer $1
Run Code Online (Sandbox Code Playgroud)
以上是我到目前为止的代码.我试图让find找到比参数1更新的所有文件,同时只停留在当前目录中.我尝试了各种使用修剪的方法,但我似乎无法找到一种有效的方法.有什么建议?
谢谢
在iOS开发中使用xib时,我一直在阅读一些关于动画的帖子.我读到的大部分内容都是不对帧进行动画处理,而是对约束进行动画处理.我已经限制标签在启动时位于视图的中心,然后我将其设置为动画并显示登录文本字段(您看到的典型登录信息).

我这样做了动画框架,当然,当我点击文本字段时,视图将原始约束应用于"我的标题"标签并将其推回到其原始中心位置.

如何删除居中约束并添加新约束以从编程方式从顶部强制空间?
这是我的动画代码:
[UIView animateWithDuration: 0.8
delay: 1.0
usingSpringWithDamping: 0.8
initialSpringVelocity: 0.5
options: UIViewAnimationOptionCurveEaseOut
animations: ^{
self.titleLabel.frame = CGRectOffset(self.titleLabel.frame, 0, -self.view.frame.size.height/4.5);
} completion: ^(BOOL finished) {
if (finished)
{
[UIView animateWithDuration: 0.8
delay: 0.3
usingSpringWithDamping: 0.8
initialSpringVelocity: 0.5
options: UIViewAnimationOptionCurveEaseInOut
animations: ^{
self.userIdTextField.alpha = 1.0;
self.userPasswordTextField.alpha = 1.0;
self.loginButton.alpha = 1.0;
} completion: ^(BOOL finished) {
}];
}
}];
Run Code Online (Sandbox Code Playgroud)