Pra*_*nna 5 docker github-actions
这将是一本不错的读物,所以我非常感谢您的帮助:bow:
我正在尝试编写一个 github 操作配置来执行以下两个任务:
autodeploy.xar在构建文件夹中创建一个文件构建过程找不到上一步创建的文件夹/文件。所以我尝试了三件事:
尝试使用上一步中创建的文件(在 github actions 中的同一作业中),但无法运行它。
Error: buildx failed with: error: failed to solve: lstat /var/lib/docker/tmp/buildkit-mount3658977881/build/autodeploy.xar: no such file or directory尝试构建两个作业,一个用于启动文件,另一个用于needs第一个构建 docker。但是,这会产生与步骤 1 相同的错误。
尝试从任务 1 构建 docker 镜像
docker build .,但 github 操作抱怨 "docker build" requires exactly 1 argument.docker build . --file Dockerfile --tag ***/***:latest --build-arg ADMIN_PASSWORD=***这一定是非常微不足道的事情,但我不知道出了什么问题。我认为其中任何一种方法的解决方案都应该有效。
再次感谢您经历这一切。请在下面找到 GH 操作、workflow.sh 和 docker 文件:
GitHub actions yml 文件:
name: ci
on:
push:
branches:
- 'build'
jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run script to replace template file
run: |
build/workflow.sh
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: ${{secrets.DOCKERHUB_USERNAME}}/${{secrets.REPO_NAME}}:latest
build-args: |
ADMIN_PASSWORD=${{secrets.ADMIN_PASSWORD}}
Run Code Online (Sandbox Code Playgroud)
工作流程文件:
# run the ant
ant <--------- This command just creates autodeploy.xar file and puts it inside the build directory
#### I TESTED WITH AN ECHO COMMAND AND THE FILES ARE ALL THERE:
# echo $(ls build)
Run Code Online (Sandbox Code Playgroud)
泊坞窗文件:
# Specify the eXist-db release as a base image
FROM existdb/existdb:6.0.1
COPY build/autodeploy.xar /exist/autodeploy/ <------ THIS LINE FAILS
COPY conf/controller-config.xml /exist/etc/webapp/WEB-INF/
COPY conf/exist-webapp-context.xml /exist/etc/jetty/webapps/
COPY conf/conf.xml /exist/etc
# Ports
EXPOSE 8080 8444
ARG ADMIN_PASSWORD
ENV ADMIN_PASSWORD=$ADMIN_PASSWORD
# Start eXist-db
CMD [ "java", "-jar", "start.jar", "jetty" ]
RUN [ "java", "org.exist.start.Main", "client", "--no-gui", "-l", "-u", "admin", "-P", "", "-x", "sm:passwd('admin','$ADMIN_PASSWORD')" ]
Run Code Online (Sandbox Code Playgroud)
错误提示找不到文件:
#5 [2/6] COPY build/autodeploy.xar /exist/autodeploy/
#5 ERROR: lstat /var/lib/docker/tmp/buildkit-mount3658977881/build/autodeploy.xar: no such file or directory
#4 [1/6] FROM docker.io/existdb/existdb:6.0.1@sha256:fa537fa9fd8e00ae839f17980810abfff6230b0b9873718a766b767a32f54ed6
Run Code Online (Sandbox Code Playgroud)
Pra*_*nna 12
这很愚蠢,但我唯一需要改变的是context: .github 操作中的
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3914 次 |
| 最近记录: |