Skip to content

Commit

Permalink
feat: Add the ability to run app and tests in a container
Browse files Browse the repository at this point in the history
  • Loading branch information
maiisthebest committed Mar 4, 2024
1 parent e8b1de9 commit 1c662f1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
24 changes: 24 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:lts-alpine

WORKDIR /usr/src/app

COPY package*.json ./
RUN npm install
COPY . .

EXPOSE 3000

CMD ["npm", "start"]
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# toy-robot-nodejs

A toy robot simulator written in NodeJs
A toy robot simulator written in NodeJs.

## About the project

Expand All @@ -16,10 +16,25 @@ To get started with this project, follow these simple steps:
1. `npm start` in the root directory to start the app.
1. The app will start and you can enter commands to play with the robot. Follow the prompts for more details.

### Running app in a container

If you have trouble running the app directly or don't want to install any dependencies, you can run the app in a container using the premade [Dockerfile](./Dockerfile).

1. Make sure you have `docker` installed. Follow these [instructions](https://docs.docker.com/engine/install/) to install. An alternative is `podman` which is also open source ([instructions](https://podman.io/)).
1. Navigate to the root directory and build the image `docker build -t robot-app .`
1. Start the app by entering `docker run -it robot-app npm start`

## Running the tests

This project was created using test-driven development because I truly care about quality 🤩 Many test cases were considered including happy path, error cases, edge cases when developing the app. Test data are part of the test files.

1. `npm test` to run all the unit tests available.

I hope you find this project enjoyable and fun. Happy roboting 🤖
### Testing in a container

You can also run the tests in a container.

1. Follow all the instructions to build the image specified in [Running app in a container](#running-app-in-a-container)
1. Run the tests by entering `docker run -t robot-app npm test`

I hope you find this project enjoyable and fun. Happy roboting 🤖🤖🤖

0 comments on commit 1c662f1

Please sign in to comment.