question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[core] allow asset bundling on docker remote host / docker in docker

See original GitHub issue

Core AssetStaging is now exposing a bundling option key allowing assets to be built before being uploaded through a docker image. Unfortunately the docker command is now using volume mount flags to mount input and output folder, making it impossible to execute if docker is set to run on a remote host or in a docker-in-docker env.

Use Case

I encountered this problem trying to build a couple of lambdas (and a custom resource provider) written in typescript on a Gitlab CI instance with docker-in-docker or executing docker commands via docker-machine.

Proposed Solution

My proposal is to create two temporary volumes on target docker env, one for inputs and one for outputs. Then the first volume can be filled running a busybox image as helper and calling docker cp to fill the volume. Once the cp has finished the helper is stopped and the build command is invoked. After that, if exit code is 0, another helper is started and the docker cp is used to copy outputs back to the cdk env.

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:21
  • Comments:29 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
pkasravicommented, Jun 11, 2021

@AntonUspehov sure no problem!

name: CDK Deploy Pipeline
on:
  workflow_dispatch:
    inputs:
      deployEnv:
        description: "Deployment Environment (dev/prod)"
        required: true

jobs:
  Deploy:
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Use Node.js
        uses: actions/setup-node@v2
        with:
          node-version: "14.15.1"

      - name: Install CDK
        run: |
          npm install -g aws-cdk

      - name: Use Python 3.8
        uses: actions/setup-python@v2
        with:
          python-version: "3.8"

      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: ${{ secrets.AWS_REGION }}

      - name: Run CDK Deploy
        run: |
          pip install -r requirements.txt
          cdk deploy my-stack
2reactions
katrinabrockcommented, Mar 18, 2021

@pkasravi yes!

I solved it by making cdk.out a mounted volume with the exact same path within the docker container as it is on the host.

https://github.com/katrinabrock/aws-cdk-dind-py-lambda/blob/master/docker-compose.yml#L8

I’m not sure if this is possible with github actions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to deploy on remote Docker hosts with docker-compose
This will allow us to run all the docker commands directly on the remote host without passing the context argument on each command....
Read more >
Docker executor - GitLab Docs
GitLab Runner uses the Docker executor to run jobs on Docker images. You can use the Docker executor to: Maintain the same build...
Read more >
aws-cdk/aws-ecr-assets module - AWS Documentation
This module allows bundling Docker images as assets. Images from Dockerfile. Images are built from a local Docker context directory (with a Dockerfile...
Read more >
Containers on Compute Engine - Google Cloud
You can also run Docker on Windows Server 2016 or later. ... Includes: Docker; Image project: windows-cloud; Image family: windows-2019-core-for-containers.
Read more >
Build images on GitHub Actions with Docker layer caching
Cut your Docker build times by half by leveraging the power BuildKit and buildx on a GitHub Action runner. Enable Docker layer caching...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found