-
Create a new folder for your new angular app
$ mkdir blog-front-app $ cd blog-front-app -
Create a new
Docker.angularfile with the below contentFROM node:16.20.0-alpine as angular-app-creator # You can change app folder name as per your wish WORKDIR /blog-front-app # fetch dependencies RUN apk update && npm install -g @angular/cliYou can use the different node image file as per your requirement.
-
After creating the
Dockerfile.angularRun below command to build the Docker image.$ docker build -f Dockerfile.angular -t angular-app-creator:latest . -
Now you can check the created image by running
docker image lscommand. -
Use newly created image to generate new angular app by running container using that image.
$ docker run --rm -it -v $(pwd):/angular-app -v blog-front-app-bundle-cache:/bundle angular-app-creatorIt will open
bashshell to run ubuntu command. Now run theng new .command in containerbashshell to generate new angular app.$ ng new blog-front-app --directory ./
Pass
--directoryoption with app name to generate app directory structures in current folder. So in our case, it will not create new folderblog-fornt-appand just generate all directory structures in current directoy and use app name in configuration file. -
Now you can check created directory structure in your local system in the same folder(eg,
/blog-front-app).
Created
April 11, 2023 14:35
-
-
Save jigneshkhokhani/ec3db17ffc59813492c05f2982254d09 to your computer and use it in GitHub Desktop.
angular-new-docker-app-creator : Create new angular app from docker it-self. It will create full angular directory without installing anything in local system.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3.8' | |
| services: | |
| front: | |
| build: | |
| context: . | |
| container_name: angular_app | |
| ports: | |
| - 4200:4200 | |
| volumes: | |
| - .:/front-app | |
| tty: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM node:16-alpine | |
| WORKDIR /front-app | |
| COPY package*.json ./ | |
| RUN npm install | |
| # Mentioned exposed port for documentation | |
| EXPOSE 4200 | |
| CMD ["npm", "start"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM node:16.20.0-alpine as angular-app-creator | |
| WORKDIR /front-app | |
| # fetch dependencies | |
| RUN apk update && npm install -g @angular/cli |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment