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.

🚀 Feature Request : Docker local build image .

See original GitHub issue

Description

Hi all I see aws cdk have this https://docs.aws.amazon.com/cdk/api/latest/docs/aws-ecr-assets-readme.html DockerImageAsset I can use new DockerImageAsset help me build my local Dockerfile to image and push to AWS ECR

import { DockerImageAsset } from '@aws-cdk/aws-ecr-assets';

const asset = new DockerImageAsset(this, 'MyBuildImage', {
  directory: path.join(__dirname, 'my-image')
});

Is it possible to have a similar method to help us build image via local Dockerfile and then push it to GCP Container Registry or Azure Container Registry… ?? like

import {DockerImageAsset} from '@cdk-terraform/docker-assets';

const asset = new DockerImageAsset(this,'MyBuildImage', {
   directory: path.join(__dirname,'my-image')
});

I just do something test like that … 🙂🙂🙂🙂🙂🙂🙂🙂 docker-assert.ts

import { exec } from 'child_process';
export function dockerAsserts(
  imagename: string,
  cwpath: string,
  credentialsName: string
) {
  exec(
    `docker build -t ${imagename} ${cwpath}/images && cat ${cwpath}/${credentialsName} | docker login -u _json_key --password-stdin asia.gcr.io && docker push ${imagename}`
  );
}

main.ts

import { Construct } from 'constructs';
import { App, TerraformStack, TerraformOutput } from 'cdktf';
import {
  CloudRunService,
  GoogleProvider,
  DataGoogleIamPolicy,
  CloudRunServiceIamPolicy,
} from './.gen/providers/google';
import * as path from 'path';
import * as fs from 'fs';
import { dockerAsserts } from './src/index';
class MyStack extends TerraformStack {
  constructor(scope: Construct, name: string) {
    super(scope, name);

    // define resources here
    const imagename = 'asia.gcr.io/${project-id}/nginx:v4';
    dockerAsserts(imagename, `${process.cwd()}`, 'google.json');
...

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
skorfmanncommented, Aug 19, 2020

@guan840912 here’s an example for AWS ECR.

It could be an interesting experiment, to build something like a generic Docker asset, which works with AWS / Google & Azure.

1reaction
skorfmanncommented, Apr 22, 2021

This is something to consider when working on #648

Read more comments on GitHub >

github_iconTop Results From Across the Web

docker build - Docker Documentation
The docker build command builds Docker images from a Dockerfile and a “context”. A build's context is the set of files located in...
Read more >
Create a base image - Docker Documentation
How to create base images. ... We have some examples below, and you are encouraged to submit pull requests to contribute new ones....
Read more >
Image-building best practices - Docker Documentation
You must be logged in to Docker Hub to scan your images. Run the command docker scan --login , and then scan your...
Read more >
docker image build
Options🔗 ; --secret, Secret file to expose to the build (only if BuildKit enabled): id=mysecret,src=/local/secret ; --security-opt, Security options ; --shm-size ...
Read more >
FastAPI in Containers - Docker
Okay, let's build something now! 🚀. I'll show you how to build a Docker image for FastAPI from scratch, based on the official...
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