gpt4 book ai didi

node.js - 配置 Dockerfile 以设置 AWS 配置

转载 作者:太空宇宙 更新时间:2023-11-04 02:57:53 27 4
gpt4 key购买 nike

我刚刚开始研究Docker。我有一个 Node 应用程序,可以调整大小和图像,然后在完成后向 aws 发送 SQS 消息。我已成功创建应用程序的 docker 镜像,并从本地计算机复制它,但遇到了无法设置包含 client_idclient_secretAWS 变量来发送 SQS 消息的问题。

以前有人遇到过这个问题吗?

我需要在 dockerfile 中编写哪些命令才能设置 aws 变量?

这是我的dockerfile:

FROM ubuntu:latest

#install node and npm
RUN apt-get update && \
apt-get -y install curl && \
curl -sL https://deb.nodesource.com/setup | sudo bash - && \
apt-get -y install python build-essential nodejs

#install imagemagick, graphicsmagick and set-up aws-cli to send SQS messages
RUN sudo apt-get -y install imagemagick
RUN sudo apt-get -y install graphicsmagick
RUN sudo apt-get install unzip
RUN curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
RUN unzip awscli-bundle.zip
RUN sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

#set-up environment variables for AWS


#at some point set-up git and fetch repository from git


# Provides cached layer for node_modules
ADD package.json /tmp/package.json
RUN cd /tmp && npm install
RUN mkdir -p /home/image-resizer && cp -a /tmp/node_modules /home/image-resizer/

#bundle source code into image
COPY . /home/image-resizer

最佳答案

您可以使用ENV在docker中设置环境变量。例如。

ENV PORT=9000
ENV LANG=en_US.utf8

但是, secret 信息不应嵌入到 Dockerfile 中,您可以使用 -e 参数传递或使用文本文件并通过 --env-file 参数传递给 docker。当使用 SVN 或 git 时,您应该忽略该文本文件。

关于node.js - 配置 Dockerfile 以设置 AWS 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30873539/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com