我正在使用本指南使用 Amazon Lex 和 Raspberry Pi 构建语音套件,但我需要使用 Docker。问题是指南卷曲和运行的脚本需要访问 /dev/tty。我可以在运行docker 容器时授予对 /dev/tty 的访问权限,但是在构建容器时我不知道如何做到这一点。
我的 Dockerfile 看起来像这样:
FROM resin/rpi-raspbian
WORKDIR /app
ADD . /app
#The script requires these
RUN apt-get update
RUN apt-get install iputils-ping
#The script has to be run with sudo priviliges but not as root
USER root
ADD /sudoers.txt /etc/sudoers
RUN chmod 440 /etc/sudoers
RUN useradd -ms /bin/bash lex
RUN echo 'lex:test' | chpasswd
RUN curl https://get.pimoroni.com/phatdac | bash
USER lex
EXPOSE 80
#Comment the …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个简单的游戏网上商店。这个想法是,开发人员可以上传将在 iframe 上显示的游戏(因此游戏只是 URL),然后就可以玩它们。
问题是,发布游戏时,图标图像不会上传。所以无法显示图像。
游戏模型:
class Game(models.Model):
name = models.CharField(max_length=255)
url = models.CharField(max_length=255)
price = models.DecimalField(max_digits=9, decimal_places=2)
developer = models.CharField(max_length=255, blank=True, null=True)
icon = models.ImageField(upload_to="images/", default="images/default_game_img.png")
description = models.CharField(max_length=255)
published = models.DateField(auto_now=False, auto_now_add=True)
Run Code Online (Sandbox Code Playgroud)
我使用 Django ModelForm:
class PublishForm(forms.ModelForm):
class Meta:
model = Game
fields = ['name', 'description', 'url', 'price', 'icon']
widgets = {
'description': Textarea(attrs={
'cols': 80,
'rows': 4,
'class': 'form-control'
}),
}
Run Code Online (Sandbox Code Playgroud)
表格的生成方式很简单:
<form class="form-horizonal" name="uploadform" enctype="multipart/form-data" method="post">
{% csrf_token %}
{{ form }}
<div class="controls">
<button type="submit" …
Run Code Online (Sandbox Code Playgroud)