# NetfoundryUi

## Generating new libs/components

Generate a new library or feature
`nx g lib feature/mylib`
`nx g lib shared/mylib`

To add a new component within an existing feature (do this if they're coupled together and will always go together)

`nx g component my-component --project=feature-mylib`

If you're not sure what the feature slug is, look in the angular.json file for the project name.

This project was generated using [Nx](https://nx.dev).

## Quick Start & Documentation

[Nx Documentation](https://nx.dev/angular)

[10-minute video showing all Nx features](https://nx.dev/angular/getting-started/what-is-nx)

[Interactive Tutorial](https://nx.dev/angular/tutorial/01-create-application)

# Jenkins and Docker

Our Jenkinsfile uses a Docker image for the build. The lasted image allows us to run Cypress tests
in the same container as the rest of the build.

To optimize run time, the Docker image is prebuilt and stored on Dockerhub
To create a fresh image...

1. docker build -t netfoundry/netfoundry-ui-build:VERSION -f Dockerfile.build .
2. test image as described below
3. docker login docker.io (use netfoundry docker credentials)
4. docker push netfoundry/netfoundry-ui-build:VERSION
5. Update the image version in the Jenkinsfile Dockerfile (not Dockerfile.build) "FROM netfoundry/netfoundry-ui-build:
   VERSION"

### Why do we build a Dockerfile in the Jenkinsfile instead of directly calling the Docker image?

When we call the docker image directly Jenkins is prepending jenkins.tools.netfoundry.io to the image name.

```
docker pull jenkins.tools.netfoundry.io/netfoundry/netfoundry-ui-build:1.0.0
Error response from daemon: Get https://jenkins.tools.netfoundry.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
script returned exit code 1
```

When we make the image part of a docker build it correctly pulls from docker.io

## Testing the Jenkins Docker container

1. docker build -t "some image name" .
2. docker run -d -t "some image name" /bin/zsh -c "tail -f /dev/null"
3. docker container ls (displays running containers - you need the id)
4. docker exec -it "container id" "some command"
5. docker exec -it "container id" /bin/zsh <<== will give you an interactive terminal
6. docker stop "container id"

### Example mounting local build env

docker run --mount type=bind,source="D:\Users\ed\IdeaProjects\WebstormProjects\docker\netfoundry-ui"
,target=/app/netfoundry-ui -it netfoundry/netfoundry-ui-build:1.1.5 /bin/zsh
