首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从内部构建Dockerfile

从内部构建Dockerfile
EN

Stack Overflow用户
提问于 2022-10-30 17:46:55
回答 1查看 89关注 0票数 0

所以我试着遵循这些指令:

代码语言:javascript
运行
复制
https://github.com/open-forest/sendy

我正在使用维护者,并试图运行一个Sendy容器(通讯软件)。我不是用它运行MySQL映像,而是使用外部托管数据库。

在我的服务器上,我将项目数据保存在: /var/docker/ project -name。如果我需要从一开始就将数据带到容器中,我就使用这个结构进行绑定安装。

因此,对于这个项目,在项目名称文件夹中,我有sendy-6.0.2.zip和这个Dockerfile:(这个文件是通过上面链接上的说明提供的)

代码语言:javascript
运行
复制
#
# Docker with Sendy Email Campaign Marketing
#
# Build:
# $ docker build -t sendy:latest --target sendy -f ./Dockerfile .
#
# Build w/ XDEBUG installed
# $ docker build -t sendy:debug-latest --target debug -f ./Dockerfile .
#
# Run:
# $ docker run --rm -d --env-file sendy.env sendy:latest

FROM php:7.4.8-apache as sendy

ARG SENDY_VER=6.0.2
ARG ARTIFACT_DIR=6.0.2

ENV SENDY_VERSION ${SENDY_VER}

RUN apt -qq update && apt -qq upgrade -y \
  # Install unzip cron
  && apt -qq install -y unzip cron  \
  # Install php extension gettext
  # Install php extension mysqli
  && docker-php-ext-install calendar gettext mysqli \
  # Remove unused packages
  && apt autoremove -y 

# Copy artifacts
COPY ./artifacts/${ARTIFACT_DIR}/ /tmp

# Install Sendy
RUN unzip /tmp/sendy-${SENDY_VER}.zip -d /tmp \
  && cp -r /tmp/includes/* /tmp/sendy/includes \
  && mkdir -p /tmp/sendy/uploads/csvs \
  && chmod -R 777 /tmp/sendy/uploads \
  && rm -rf /var/www/html \
  && mv /tmp/sendy /var/www/html \
  && chown -R www-data:www-data /var/www \
  && mv /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini \
  && rm -rf /tmp/* \
  && echo "\nServerName \${SENDY_FQDN}" > /etc/apache2/conf-available/serverName.conf \
  # Ensure X-Powered-By is always removed regardless of php.ini or other settings.
  && printf "\n\n# Ensure X-Powered-By is always removed regardless of php.ini or other settings.\n\
  Header always unset \"X-Powered-By\"\n\
  Header unset \"X-Powered-By\"\n" >> /var/www/html/.htaccess \
  && printf "[PHP]\nerror_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED\n" > /usr/local/etc/php/conf.d/error_reporting.ini

# Apache config
RUN a2enconf serverName

# Apache modules
RUN a2enmod rewrite headers

# Copy hello-cron file to the cron.d directory
COPY cron /etc/cron.d/cron
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/cron \
  # Apply cron job
  && crontab /etc/cron.d/cron \
  # Create the log file to be able to run tail
  && touch /var/log/cron.log

COPY artifacts/docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["apache2-foreground"]

#######################
# XDEBUG Installation
#######################
FROM sendy as debug
# Install xdebug extension
RUN pecl channel-update pecl.php.net \
  && pecl install xdebug \
  && docker-php-ext-enable xdebug \
  && rm -rf /tmp/pear 

这是我的码头撰写文件:

代码语言:javascript
运行
复制
version: '3.7'

services:

    project-sendy:
        container_name: project-sendy
        image: sendy:6.0.2
        build: 
          dockerfile: var/docker/project-sendy/Dockerfile
        restart: unless-stopped
        networks:
          - proxy
          - default
        labels:
          - "traefik.enable=true"
          - "traefik.docker.network=proxy"
          - "traefik.http.routers.project-secure.entrypoints=websecure"
          - "traefik.http.routers.project-secure.rule=Host(`project.com`)"
        environment:
          SENDY_PROTOCOL: https
          SENDY_FQDN: project.com
          MYSQL_HOST: db-host-name-here
          MYSQL_DATABASE: db-name-here
          MYSQL_USER: db-user-name-here
          MYSQL_PASSWORD: db-password-here
          SENDY_DB_PORT: db-port-here
          

networks:
  proxy:
    external: true  

当我尝试部署时,我得到:

代码语言:javascript
运行
复制
failed to deploy a stack: project-sendy Pulling project-sendy 
Error could not find /data/compose/126/var/docker/project-sendy: 
stat /data/compose/126/var/docker/project-sendy: no such file or directory
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-30 22:50:04

这就是我所做的。

我在与Dockerfile相同的目录中有cron和工件文件夹。在Dockerfile中查找以下行:

代码语言:javascript
运行
复制
COPY artifacts/docker-entrypoint.sh /usr/local/bin/

就在它下面写着:

代码语言:javascript
运行
复制
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

否则,您将得到以下错误:

代码语言:javascript
运行
复制
Starting Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/usr/local/bin/docker-entrypoint.sh": permission denied: unknown 

然后用以下方法构建它:

代码语言:javascript
运行
复制
docker build -t sendy:6.0.2 .

然后你的形象就会出现在预言家。

然后,您可以删除停靠器撰写文件中的生成部分,然后单击deploy。现在对我来说很管用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74255367

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档