🚀 Feature Request : Docker local build image .
See original GitHub issueDescription
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:
- Created 3 years ago
- Reactions:2
- Comments:9 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
This is something to consider when working on #648