From 337a898f7753551600185de64352eefdef51bb6a Mon Sep 17 00:00:00 2001 From: KEINOS Date: Wed, 16 Jun 2021 15:09:47 +0900 Subject: [PATCH] fix: Dockerfile --- .devcontainer/devcontainer.json | 6 ++++- Dockerfile | 45 +++++++++++++++++++++++++++++---- docker-compose.test.yml | 8 ++++++ 3 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 docker-compose.test.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0edae29..b11b620 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -15,7 +15,11 @@ // Add the IDs of extensions you wanït installed when the container is created. // Note that some extensions may not work in Alpine Linux. See https://aka.ms/vscode-remote/linux. - "extensions": ["foxundermoon.shell-format", "esbenp.prettier-vscode"], + "extensions": [ + "foxundermoon.shell-format", + "esbenp.prettier-vscode", + "ms-azuretools.vscode-docker" + ], // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], diff --git a/Dockerfile b/Dockerfile index 3ecae84..aa0b8db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,47 @@ -# QiiCipher のコマンドだけを含めた Alpine イメージです +# ============================================================================= +# QiiCipher for Docker +# ============================================================================= +# QiiCipher のコマンドだけを含めた Alpine イメージです。 +# マルチステージ・ビルドでテストを実行し、成功した場合のみ QiiCipher のコマンドだけを含めた +# シンプルなイメージを作成します。docker-compose.test.yml により Docker Hub からのダウ +# ンロード(`docker pull`)が可能になります。 + +# ----------------------------------------------------------------------------- +# Test Stage +# ----------------------------------------------------------------------------- +FROM shellspec/shellspec:latest AS testbuild + +# Install miminum requirements for QiiCipher +RUN apk add --no-cache \ + openssl \ + openssh \ + ca-certificates && update-ca-certificates + +# Install requirements for testing +RUN apk add --no-cache \ + git \ + shellcheck \ + shfmt + +# Copy the hole repo +COPY . /app +WORKDIR /app + +# Run tests +RUN \ + /app/.github/run-lint.sh \ + && /app/.github/run-test.sh + +# ----------------------------------------------------------------------------- +# Final Stage +# ----------------------------------------------------------------------------- FROM alpine RUN apk add --no-cache \ - bash \ - curl \ openssl \ + openssh \ ca-certificates && update-ca-certificates -COPY ./bin /usr/local/sbin +COPY --from=testbuild /app/bin /usr/local/sbin -CMD ["/bin/ls","/bin/local/sbin"] +CMD ["/bin/ls","/usr/local/sbin"] diff --git a/docker-compose.test.yml b/docker-compose.test.yml new file mode 100644 index 0000000..fbd80a5 --- /dev/null +++ b/docker-compose.test.yml @@ -0,0 +1,8 @@ +# Test for Docker Cloud Automated Build +sut: + build: . + volumes: + # Mount test file + - ./run-test_docker-cloud.sh:/app/run-test.sh + # Run the mounted test file inside a container from the built image + entrypoint: enc --help