Compare commits

...

40 Commits

Author SHA1 Message Date
ab4275c430 5.0.146
All checks were successful
Docker (tags) / security (push) Successful in 38s
Docker (tags) / test (push) Successful in 55s
Docker (tags) / metadata (push) Successful in 6s
Docker (tags) / release (push) Successful in 14m46s
2024-11-17 20:24:00 +01:00
76c86e09c1 fix(Dockerfiles): Correct Docker image source host in various Dockerfiles 2024-11-17 20:24:00 +01:00
f2ab850e19 5.0.145
Some checks failed
Docker (tags) / security (push) Successful in 39s
Docker (tags) / test (push) Successful in 54s
Docker (tags) / metadata (push) Successful in 6s
Docker (tags) / release (push) Failing after 42s
2024-11-17 20:16:21 +01:00
29c707d79f fix(docs): Minor documentation updates without code changes. 2024-11-17 20:16:20 +01:00
5789c4eea6 5.0.144
Some checks failed
Docker (tags) / security (push) Successful in 36s
Docker (tags) / test (push) Successful in 54s
Docker (tags) / metadata (push) Successful in 6s
Docker (tags) / release (push) Failing after 15m41s
2024-11-17 07:57:21 +01:00
52369e55db fix(ci): Update Docker container source for workflow to new registry 2024-11-17 07:57:21 +01:00
13aadf4730 5.0.143
Some checks failed
Docker (tags) / security (push) Successful in 44s
Docker (tags) / test (push) Successful in 54s
Docker (tags) / metadata (push) Successful in 7s
Docker (tags) / release (push) Failing after 29s
2024-11-17 07:47:16 +01:00
41cf74c307 fix(core): No uncommitted changes 2024-11-17 07:47:16 +01:00
8e48786393 5.0.142
All checks were successful
Docker (tags) / security (push) Successful in 37s
Docker (tags) / test (push) Successful in 44s
Docker (tags) / metadata (push) Successful in 5s
Docker (tags) / release (push) Successful in 1m8s
2024-05-26 14:39:43 +02:00
a00d36cf95 fix(core): update 2024-05-26 14:39:42 +02:00
69ee21ed1b 5.0.141
Some checks failed
Docker (tags) / security (push) Failing after 0s
Docker (tags) / test (push) Has been skipped
Docker (tags) / release (push) Has been skipped
Docker (tags) / metadata (push) Has been skipped
2024-05-26 14:02:48 +02:00
39bd0ea990 fix(core): update 2024-05-26 14:02:47 +02:00
cfc7ef07cf 5.0.140
Some checks failed
Docker (tags) / security (push) Failing after 0s
Docker (tags) / test (push) Has been skipped
Docker (tags) / release (push) Has been skipped
Docker (tags) / metadata (push) Has been skipped
2024-05-26 14:01:44 +02:00
356dda054f fix(core): update 2024-05-26 14:01:43 +02:00
f0b993d9c0 5.0.139
All checks were successful
Docker (tags) / security (push) Successful in 37s
Docker (tags) / test (push) Successful in 45s
Docker (tags) / metadata (push) Successful in 5s
Docker (tags) / release (push) Successful in 7m16s
2024-05-26 13:15:30 +02:00
75d68d1f2b fix(core): update 2024-05-26 13:15:30 +02:00
e9f77f7042 5.0.138
All checks were successful
Docker (tags) / security (push) Successful in 38s
Docker (tags) / test (push) Successful in 44s
Docker (tags) / metadata (push) Successful in 5s
Docker (tags) / release (push) Successful in 2m16s
2024-05-26 11:34:41 +02:00
18e6b59ab1 5.0.137
All checks were successful
Docker (tags) / security (push) Successful in 38s
Docker (tags) / test (push) Successful in 46s
Docker (tags) / metadata (push) Successful in 5s
Docker (tags) / release (push) Successful in 7m9s
2024-05-26 11:04:58 +02:00
2c2685dbcb fix(core): update 2024-05-26 11:04:57 +02:00
592d71de80 5.0.136
Some checks failed
Docker (tags) / security (push) Successful in 28s
Docker (tags) / test (push) Successful in 47s
Docker (tags) / metadata (push) Successful in 5s
Docker (tags) / release (push) Failing after 59s
2024-05-26 00:15:01 +02:00
2702d68891 5.0.135
Some checks failed
Docker (tags) / security (push) Successful in 38s
Docker (tags) / test (push) Successful in 44s
Docker (tags) / metadata (push) Successful in 5s
Docker (tags) / release (push) Failing after 21s
2024-05-26 00:11:49 +02:00
a04530e50c fix(core): update 2024-05-26 00:11:49 +02:00
c3e2190907 5.0.134
Some checks failed
Docker (tags) / security (push) Successful in 27s
Docker (tags) / test (push) Successful in 43s
Docker (tags) / metadata (push) Successful in 5s
Docker (tags) / release (push) Failing after 27s
2024-05-24 15:53:37 +02:00
8d9767035d fix(core): update 2024-05-24 15:53:36 +02:00
5bbf3e20fb 5.0.133
Some checks failed
Docker (tags) / security (push) Successful in 36s
Docker (tags) / test (push) Successful in 43s
Docker (tags) / metadata (push) Successful in 5s
Docker (tags) / release (push) Failing after 59s
2024-05-24 15:53:20 +02:00
5266959d11 fix(core): update 2024-05-24 15:53:20 +02:00
ca92e81fae 5.0.132
Some checks failed
Docker (tags) / security (push) Successful in 37s
Docker (tags) / test (push) Successful in 47s
Docker (tags) / metadata (push) Successful in 5s
Docker (tags) / release (push) Failing after 59s
2024-05-24 13:15:38 +02:00
47a7b99e55 fix(core): update 2024-05-24 13:15:37 +02:00
f945921591 5.0.131
Some checks failed
Docker (tags) / security (push) Successful in 29s
Docker (tags) / test (push) Successful in 54s
Docker (tags) / metadata (push) Successful in 5s
Docker (tags) / release (push) Failing after 7m26s
2024-05-24 13:05:17 +02:00
c0aaf75f4f fix(core): update 2024-05-24 13:05:16 +02:00
5f64057cdb 5.0.130
Some checks failed
Docker (tags) / security (push) Successful in 33s
Docker (tags) / test (push) Successful in 47s
Docker (tags) / metadata (push) Successful in 5s
Docker (tags) / release (push) Failing after 21s
2024-05-24 13:02:38 +02:00
d84919c3e6 fix(core): update 2024-05-24 13:02:37 +02:00
1db9b7978a 5.0.129
Some checks failed
Docker (tags) / security (push) Successful in 26s
Docker (tags) / test (push) Successful in 44s
Docker (tags) / metadata (push) Successful in 5s
Docker (tags) / release (push) Failing after 23s
2024-05-24 12:59:19 +02:00
ba19c565f6 fix(core): update 2024-05-24 12:59:19 +02:00
bcdd4d2acb 5.0.128
Some checks failed
Docker (tags) / security (push) Successful in 27s
Docker (tags) / test (push) Successful in 44s
Docker (tags) / metadata (push) Successful in 5s
Docker (tags) / release (push) Failing after 26s
2024-05-24 12:59:00 +02:00
662b888a35 fix(core): update 2024-05-24 12:58:59 +02:00
004ce39822 5.0.127
Some checks failed
Docker (tags) / security (push) Failing after 22s
Docker (tags) / test (push) Has been skipped
Docker (tags) / release (push) Has been skipped
Docker (tags) / metadata (push) Has been skipped
2024-05-24 12:57:16 +02:00
c1fb329671 fix(core): update 2024-05-24 12:57:15 +02:00
c2813373aa 5.0.126 2024-05-23 21:59:57 +02:00
617fa0f082 fix(core): update 2024-05-23 21:59:56 +02:00
15 changed files with 545 additions and 112 deletions

View File

@ -0,0 +1,71 @@
name: Docker (tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_LOGIN_DOCKER_GITEA: ${{ github.server_url }}|${{ gitea.repository_owner }}|${{ secrets.GITEA_TOKEN }}
NPMCI_LOGIN_DOCKER_DOCKERREGISTRY: ${{ secrets.NPMCI_LOGIN_DOCKER_DOCKERREGISTRY }}
jobs:
security:
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci npm prepare
npmci node install stable
npmci npm install
npmci command npm run build

View File

@ -0,0 +1,106 @@
name: Docker (tags)
on:
push:
tags:
- '*'
env:
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
# NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
# NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
# NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
# NPMCI_LOGIN_DOCKER_GITEA: ${{ github.server_url }}|${{ gitea.repository_owner }}|${{ secrets.GITEA_TOKEN }}
NPMCI_LOGIN_DOCKER_DOCKERREGISTRY: ${{ secrets.NPMCI_LOGIN_DOCKER_DOCKERREGISTRY }}
jobs:
security:
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci command npm run build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: code.foss.global/host.today/ht-docker-dbase:npmci
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
- name: Release
run: |
npmci docker login
npmci docker build
npmci docker test
# npmci docker push gitea.lossless.digital
npmci docker push code.foss.global
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Trigger
run: npmci trigger

View File

@ -1,55 +0,0 @@
# gitzone ci_docker
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci-cache/
key: "$CI_BUILD_STAGE"
before_script:
- pnpm uninstall -g @shipzone/npmci
- pnpm install -g @ship.zone/npmci
- npmci npm prepare
stages:
- test
- release
- trigger
- pages
testStable:
stage: test
script:
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
services:
- docker:stable-dind
stage: release
script:
- npmci node install lts
- npmci docker login
- npmci docker build
- npmci docker test
- npmci docker push registry.gitlab.com
- npmci docker push docker.io
only:
- tags
tags:
- docker
- priv
trigger:
stage: trigger
script:
- npmci trigger
only:
- tags
tags:
- docker

View File

@ -1,4 +1,4 @@
FROM hosttoday/ht-docker-node:alpine
FROM host.today/ht-docker-node:alpine
RUN apk update && apk add bash libc6-compat alpine-sdk
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
@ -7,4 +7,4 @@ RUN pip3 install --no-cache --upgrade pip setuptools
RUN apk add --update alpine-sdk && \
apk add libffi-dev openssl-dev && \
apk add python3-dev && \
pnpm install -g @shipzone/npmci node-gyp
pnpm install -g @ship.zone/npmci node-gyp

View File

@ -1,4 +1,4 @@
FROM hosttoday/ht-docker-node:npmci
FROM host.today/ht-docker-node:npmci
RUN npm install -g \
@git.zone/tsrun \
@git.zone/tstest \

View File

@ -1,4 +1,4 @@
FROM hosttoday/ht-docker-node:latest as stage1
FROM host.today/ht-docker-node:latest as stage1
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
RUN apt-get update && apt-get install -y --no-install-recommends qemu-user-static binfmt-support
# the following lines need to be run on a system that supports both architectures

View File

@ -1,4 +1,4 @@
FROM hosttoday/ht-docker-node:latest
FROM host.today/ht-docker-node:latest
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
RUN bash -c "source $NVM_DIR/nvm.sh \

View File

@ -1,4 +1,4 @@
FROM hosttoday/ht-docker-node:latest
FROM host.today/ht-docker-node:latest
LABEL author="Task Venture Capital GmbH <hello@task.vc>"
RUN pnpm install -g @ship.zone/npmci

View File

@ -1,4 +1,4 @@
FROM hosttoday/ht-docker-node:latest
FROM host.today/ht-docker-node:latest
# Add Tini
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini

73
changelog.md Normal file
View File

@ -0,0 +1,73 @@
# Changelog
## 2024-11-17 - 5.0.146 - fix(Dockerfiles)
Correct Docker image source host in various Dockerfiles
- Updated the source host from 'hosttoday/ht-docker-node' to 'host.today/ht-docker-node' in several Dockerfiles
## 2024-11-17 - 5.0.145 - fix(docs)
Minor documentation updates without code changes.
## 2024-11-17 - 5.0.144 - fix(ci)
Update Docker container source for workflow to new registry
- Changed Docker container image source in .gitea/workflows/docker_tags.yaml to code.foss.global.
## 2024-11-17 - 5.0.143 - fix(core)
No uncommitted changes
- No changes detected. All files are up-to-date.
## 2024-05-26 - 5.0.139 to 5.0.142 - Core updates
Routine updates to the core functionality.
## 2024-05-23 - 5.0.124 to 5.0.138 - Core updates
Routine updates to the core functionality.
## 2024-04-23 - 5.0.114 to 5.0.123 - Core updates
Routine updates to the core functionality.
## 2024-04-14 - 5.0.113 to 5.0.113 - Core updates
Routine updates to the core functionality.
## 2023-04-02 - 5.0.105 to 5.0.112 - Core updates
Routine updates to the core functionality.
## 2022-12-17 - 5.0.101 to 5.0.104 - Core updates
Routine updates to the core functionality.
## 2022-10-17 - 5.0.91 to 5.0.100 - Core updates
Routine updates to the core functionality.
## 2022-10-11 - 5.0.85 to 5.0.90 - Core updates
Routine updates to the core functionality.
## 2022-08-05 - 5.0.78 to 5.0.84 - Core updates
Routine updates to the core functionality.
## 2022-03-22 - 5.0.75 to 5.0.77 - Core updates
Routine updates to the core functionality.
## 2021-11-12 - 5.0.67 to 5.0.74 - Core updates
Routine updates to the core functionality.
## 2021-10-22 - 5.0.61 to 5.0.66 - Core updates
Routine updates to the core functionality.
## 2020-05-28 - 5.0.55 to 5.0.60 - Core updates
Routine updates to the core functionality.
## 2019-11-19 - 5.0.50 to 5.0.54 - Core and Snyk fixes
Core updates and restored Snyk to the latest version.
## 2016-08-31 - 4.3.2 to 4.3.5 - Core updates
Routine updates to the core functionality.
## 2016-06-01 - 4.3.1 - Multiple enhancements
Implemented various features and fixes in the project.
- Updated .gitlab-ci.yml multiple times
- Added Python3 support
- Added new features and fixed various issues

View File

@ -6,7 +6,20 @@
"gitrepo": "ht-docker-node",
"shortDescription": "docker image with nodejs and shipzone.io support",
"npmPackagename": "@hosttoday/ht-docker-node",
"license": "MIT"
"license": "MIT",
"description": "A Docker image that integrates Node.js with shipzone.io support.",
"keywords": [
"Docker",
"Node.js",
"shipzone.io",
"npm",
"CI",
"git",
"ssh",
"npmci",
"node version management",
"typescript"
]
}
},
"npmci": {

5
package-lock.json generated
View File

@ -1,5 +0,0 @@
{
"name": "ht-docker-node",
"version": "5.0.125",
"lockfileVersion": 1
}

View File

@ -1,7 +1,7 @@
{
"name": "ht-docker-node",
"version": "5.0.125",
"description": "docker image with nodejs and shipzone.io support",
"version": "5.0.146",
"description": "A Docker image that integrates Node.js with shipzone.io support.",
"main": "index.js",
"scripts": {
"test": "echo \"no npm test specified\"",
@ -31,5 +31,17 @@
],
"directories": {
"test": "test"
}
},
"keywords": [
"Docker",
"Node.js",
"shipzone.io",
"npm",
"CI",
"git",
"ssh",
"npmci",
"node version management",
"typescript"
]
}

9
pnpm-lock.yaml generated Normal file
View File

@ -0,0 +1,9 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.: {}

291
readme.md
View File

@ -1,59 +1,268 @@
# @hosttoday/ht-docker-node
docker image with nodejs and [ship.zone](https://ship.zone) support
# ht-docker-node
docker image with nodejs and shipzone.io support
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@hosttoday/ht-docker-node)
* [gitlab.com (source)](https://gitlab.com/hosttoday/ht-docker-node)
* [github.com (source mirror)](https://github.com/hosttoday/ht-docker-node)
* [docs (typedoc)](https://hosttoday.gitlab.io/ht-docker-node/)
## Install
## Status for master
[![build status](https://gitlab.com/hosttoday/ht-docker-node/badges/master/build.svg)](https://gitlab.com/hosttoday/ht-docker-node/commits/master)
[![coverage report](https://gitlab.com/hosttoday/ht-docker-node/badges/master/coverage.svg)](https://gitlab.com/hosttoday/ht-docker-node/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@hosttoday/ht-docker-node.svg)](https://www.npmjs.com/package/@hosttoday/ht-docker-node)
[![Known Vulnerabilities](https://snyk.io/test/npm/@hosttoday/ht-docker-node/badge.svg)](https://snyk.io/test/npm/@hosttoday/ht-docker-node)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
To get started with `ht-docker-node`, you need to have Docker installed on your machine. You can then pull the desired flavor of the Docker image from the relevant Docker registry.
Example:
```bash
docker pull registry.gitlab.com/hosttoday/ht-docker-node:latest
```
## Usage
The purpose of this Docker image is to provide a robust base for node apps and CI.
It comes in different flavours and all of them have node, npm, git and ssh in PATH.
`ht-docker-node` offers a variety of Docker image flavors to suit different needs. Below, we'll guide you through different use cases and configurations using these Docker images.
The **:npmci flavour** has npmci in path and can install any required node version and update PATH accordingly:
### Flavour Overview
```Dockerfile
FROM hosttoday/ht-docker-node:npmci
RUN npmci install [node_version_number] // this installs node using node and sets the default to the new node and npm versions
- **:lts** - Node LTS version, equivalent to :latest
- **:stable** - Node stable version
- **:npmci** - `npmci` preinstalled
- **:npmts** - `npmci` + `npmts` preinstalled
- **:npmpage** - `npmci` + `npmts` + `npmpage` preinstalled
- **:mongo** - `npmci` + `npmts` + `mongo`
### Basic Usage
To start a container with the `lts` flavour, you can use the following command:
```bash
docker run -it --name your_container_name registry.gitlab.com/hosttoday/ht-docker-node:lts
```
## Availability
### Using `npmci`
| Registry | Image Path |
| --------------- | -------------------------------------------- |
| GitLab Registry | registry.gitlab.com/hosttoday/ht-docker-node |
| Docker Hub | hosttoday/ht-docker-node |
The `:npmci` flavour includes `npmci`, a utility for managing Node.js versions and npm installations. Here's an example of how you can use it:
## Flavour Overview
```Dockerfile
FROM registry.gitlab.com/hosttoday/ht-docker-node:npmci
RUN npmci install 14.17.0
```
- **:lts** - node lts version, equals :latest
- **:stable** - node stable version
- **:npmci** - npmci preinstalled
- **:npmts** - npmci + npmts preinstalled
- **:npmpage** - npmci + npmts + npmpage preinstalled
- **:mongo** - npmci + npmts + mongo
In this example, `npmci` installs Node.js version `14.17.0` and sets it as the default.
For further information read the linked docs at the top of this README.
### Custom Dockerfile with `npmci` and your Node.js App
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
You can create a custom Dockerfile for your Node.js application using the `:npmci` flavour:
[![repo-footer](https://hosttoday.gitlab.io/assets/repo-footer.svg)](https://host.today)
```Dockerfile
# Use the ht-docker-node image with npmci
FROM registry.gitlab.com/hosttoday/ht-docker-node:npmci
For further information read the linked docs at the top of this readme.
# Install a specific Node.js version
RUN npmci install 14.17.0
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
# Create app directory
WORKDIR /usr/src/app
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
# Copy package.json and package-lock.json
COPY package*.json ./
# Install app dependencies
RUN npm install
# Bundle app source
COPY . .
# Expose port
EXPOSE 8080
# Start the application
CMD ["node", "index.js"]
```
To build the Docker image:
```bash
docker build -t your_app_name .
```
To run the container:
```bash
docker run -p 8080:8080 --name your_container_name your_app_name
```
### Multi-Stage Builds for Production
For a leaner production image, you can use multi-stage builds. Heres an example:
```Dockerfile
# Stage 1: Build
FROM registry.gitlab.com/hosttoday/ht-docker-node:npmci as build
RUN npmci install 14.17.0
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# Stage 2: Production
FROM registry.gitlab.com/hosttoday/ht-docker-node:lts
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/dist ./
EXPOSE 8080
CMD ["node", "index.js"]
```
### Using with MongoDB (`:mongo`)
The `:mongo` flavour contains a MongoDB installation alongside Node.js. Heres how you can utilize it in your Dockerfile:
```Dockerfile
FROM registry.gitlab.com/hosttoday/ht-docker-node:mongo
# Setup mongo and node environment:
RUN npm install -g mongodb
# Working directory
WORKDIR /usr/src/app
# Copy MongoDB config
COPY mongod.conf /etc/mongod.conf
# Start MongoDB service
CMD ["mongod", "--config", "/etc/mongod.conf"] && node index.js
```
### Using `npmts` and `npmpage`
The `:npmts` and `:npmpage` flavours are useful for projects that use TypeScript or require page generation.
Heres an example on how to work with `:npmts`:
```Dockerfile
FROM registry.gitlab.com/hosttoday/ht-docker-node:npmts
# Install necessary TypeScript packages
RUN npm install -g typescript
# Working directory
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of your files
COPY . .
# Compile TypeScript
RUN npm run build
# Expose port and start the server
EXPOSE 3000
CMD ["npm", "start"]
```
### Comprehensive Use Case Example
The following example covers multiple aspects including environment variables, volume mounting, and networking.
#### Dockerfile:
```Dockerfile
FROM registry.gitlab.com/hosttoday/ht-docker-node:npmci
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000
# Install desired Node.js version
RUN npmci install 16.0.0
# Create app directory
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install app dependencies
RUN npm ci
# Bundle app source
COPY . .
# Compile TypeScript
RUN npm run build
# Expose app port
EXPOSE 3000
# Start the application
CMD ["npm", "start"]
```
#### Docker-Compose Configuration
If using Docker-Compose, create a `docker-compose.yml` file:
```yaml
version: '3.8'
services:
app:
image: your_app_name
build:
context: .
dockerfile: Dockerfile
ports:
- '3000:3000'
environment:
- NODE_ENV=production
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
networks:
- app-network
networks:
app-network:
driver: bridge
```
#### Running with Docker and Docker-Compose
To build the image:
```bash
docker-compose build
```
To run the services:
```bash
docker-compose up
```
#### Accessing the Container
```bash
docker exec -it your_container_name /bin/sh
```
### Conclusion
`ht-docker-node` offers a flexible, multifaceted solution for deploying Node.js applications in Docker containers. By leveraging its different flavours, you can efficiently manage Node.js versions, incorporate MongoDB, and handle TypeScript projects. Whether you are using simple Docker commands or elaborate Docker-Compose configurations, `ht-docker-node` caters to diverse deployment scenarios.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.