Comments (13)
In that case, can I use "executor": "nx:run-commands" to run these new/updated images?
After you have the image, getting it running is another story.
I have been creating my own executors using dockerode
, perhaps I will create a library with that work some day.
As a simple alternative you can use the run-commands
executor as you mentioned to either use docker or docker-compose to start up the image locally.
The current scope of this library ends at building the image and pushing it to a registry.
There is an open feature request for a executor for running images.
#12
If you have further comments or ideas about that feature you may add those there.
from nx-tools.
@gilvaju Please check this repository, it's a sandbox with nest, react, next and angular application and all of them use the nx-docker plugin to generate the docker images
from nx-tools.
@kodeine yes... you can run npx nx affected --target=docker
(or the target which you created in the project.json)
from nx-tools.
I noticed that this package is a peer here.
https://github.com/nx-tools/nx-tools/blob/efec6c8d3fa1946f69941c4eddadc99aa6a18bbd/packages/docker-metadata/package.json#L24
This was introduced in this commit.
27b73cc
I wonder if there is an expectation of another package providing the deposit for @swc/helpers
that does not exist in your stack? Maybe @nrwl/angular
or @nrwl/web
or something like that?
Perhaps this should be moved to a dependency OR perhaps the readme should include @swc/helpers as a required peer along side tslib
and @nrwl/devkit
Perhaps this package manager specific?
I know nom has automatic peers, but others (yarn 1) may not.
from nx-tools.
+1
I would also like to know how to use docker compose
with nx-container
!
from nx-tools.
@gilvaju So what we do at work is we first build the application completely outside of Docker using the standard Nx build system. This allows reusing library builds and computational caching. And as part of the build step we put the Dockerfile
in the dist
via the assets
option.
After we have everything in assets we use nx-docker
copy the compiled Javascript into a docker image.
As part of that we do an npm install
inside the Docker image using the generated package.json
that came from the @nrwl/node:webpack
executor which only list modules that we actually used.
The one gotcha is we have to use "buildLibsFromSource": true,
to inline the library modules into the bundle of the server.
So we aren't really getting the benefit of the libraries being cached and built separately right now, but we have plans to change the webpack config to cover that case.
Overview:
- Configure a Docker file and add it to the
assets
- Build nestjs project with
@nrwl/node:webpack
- Point
@nx-tools/nx-docker:build
at the dist location of the Docker file - Build the docker image from the compiled server
- Run npm install inside the image using the package.json generated from
generatePackageJson
from nx-tools.
@gperdomor so if we have multiple nest apps and a common library. If we modify common lib would docker rebuild all apps?
from nx-tools.
@gilvaju Please check this repository, it's a sandbox with nest, react, next and angular application and all of them use the nx-docker plugin to generate the docker images
I'll see the example and then give feedback
from nx-tools.
@gilvaju Please check this repository, it's a sandbox with nest, react, next and angular application and all of them use the nx-docker plugin to generate the docker images
Hello, now that we had time to study the repository you indicated.
Anyway thanks for the link
from nx-tools.
I was only able to run the command after installing @swr
It built perfectly and so I have the image to be used as I want
In that case, can I use "executor": "nx:run-commands" to run these new/updated images?
from nx-tools.
After you have the image, getting it running is another story. I have been creating my own executors using
dockerode
, perhaps I will create a library with that work some day. As a simple alternative you can use therun-commands
executor as you mentioned to either use docker or docker-compose to start up the image locally.The current scope of this library ends at building the image and pushing it to a registry.
Hmm, I understand
We currently have an ecosystem of about 20 containers, some apps on nx and other services like postgres and mongo.
I believe if it is a way to play these other services for apps tb and use nx-tools to build the images and also use run-commands to run the images (for postgres and mongo for example I would create apps containing only project. json and the Docker file).
It will also be used with github actions
All these images are now served all on just one EC2 with haproxy as a reverse proxy. In the future we have plans to migrate to the container manager or something more complex like kubernets.
Would it be a good way?
There is an open feature request for a executor for running images. #12
If you have further comments or ideas about that feature you may add those there.
Cool, I would like to help, what would be the way? I think I can contribute something.
from nx-tools.
Im sure PRs are welcome. Maybe tag @gperdomor with a comment in issue #12 with your initial ideas and then create a draft PR?
I would think we would add a run executor or something, but I am sure there are a few ways to solve the problem.
from nx-tools.
Is there an example of how to use this with docker-compose
?
After running a docker-compose file I got the following error: Error: Cannot find module '/usr/src/app/main.js'
from nx-tools.
Related Issues (20)
- Feature request: allow setting SBOM options to container builder HOT 2
- Provenance not set in docker build command when value is 'false' HOT 1
- Crystal Support HOT 4
- NX_CONTAINER_SHORT_SHA_LENGTH documentation in container-metadata
- externalDependencies (or how to ignore package-lock.json) HOT 1
- Had to downgrade to v5.3.0 because v6.0.0 throws error HOT 2
- Incorrect Setup Documentation HOT 1
- nx-container does not support nx 17 HOT 1
- nx-container build not pushing or loading images HOT 4
- tag docker images according to the nx hash/with the nx hasher functionality HOT 2
- Nx reports success on Kaniko failure after credentials check
- (nx-tools/container) Only push to specified image repositories HOT 5
- INPUT_TAGS still not working with multiple tags
- v5.2.0 Release Notes HOT 1
- Loosen `@graphql-codegen/cli` peer dependency version HOT 2
- Tagging dosent seem to infer semver for independant tags HOT 2
- Building with kaniko results in missing packets on node_modules HOT 4
- Docker context (directory) not set consistently?
- Git fallback not working properly HOT 1
- Feature Request: Support `{absWorkspaceRoot}` and `{absProjectRoot}` token replacement for file paths HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nx-tools.