Skip to content

Commit

Permalink
Added Docker build checks
Browse files Browse the repository at this point in the history
  • Loading branch information
janik6n committed Jan 7, 2025
1 parent 5e6a647 commit e715728
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ All notable changes to this template will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.3.0] - 2025-01-07

### Added

- New script `npm run check:container`. See README for more details.

### Changed

- Updated README.

### Deprecated

### Fixed

### Removed

### Security

### Internal

## [1.2.3] - 2025-01-04

### Added
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# syntax=docker/dockerfile:1
# check=error=true

# Node build image
FROM node:22.12.0-bookworm AS builder
# Install Ubuntu packages + dumb-init
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ How to use this template?
3. Install dependencies by running `npm install` on the project root directory.
4. Start developing. See below for available scripts.

## Available scripts

Following scripts have been configured, and they should give ideas for further development.

### ⚙️ Run development server

To run TypeScript to JavaScript transpiling and to run transpiled `./dist/index.mjs` run `npm run dev`. Watch mode (a.k.a. *hot reloading*) is available with `npm run dev:watch`. Development serving is handled with [tsx](https://tsx.is/).
Expand Down Expand Up @@ -86,6 +90,10 @@ Sometimes it's necessary to see the built app with just transpiling without bund

Run the built app with `npm run start`.

### 🐳 Check container build for issues

Run `npm run check:container` to check Docker build for issues, without actually building the image. `Dockerfile` is configured so that failing checks will exit with error status. See [Build checks | Docker Docs](https://docs.docker.com/build/checks/) for more info.

### 🐳 Build as container

Run `npm run build:container` to build the app as Docker container. Multi-stage build is used to minimize the production image size. Debian-based image is used to minimize the risk of compatibility issues.
Expand All @@ -98,12 +106,12 @@ Run the containerized app with `npm run start:container`.

None as of now. 🦗

## What’s not inside
## ✂️ What’s not inside

Here are some things that *could be included* in a starter, but are not in this one:
- Monorepo setup
- Any particular app’s source code
- Git pre-commit hooks (I do not prefer to use them)
- Git pre-commit hooks

## 📚 Further reading

Expand Down Expand Up @@ -144,6 +152,7 @@ Here are some things that *could be included* in a starter, but are not in this

- https://hub.docker.com/_/node
- https://snyk.io/blog/choosing-the-best-node-js-docker-image/
- https://docs.docker.com/build/checks/

### GitHub

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "typescript-starter",
"description": "TypeScript Starter",
"version": "1.2.3",
"version": "1.3.0",
"homepage": "https://github.com/janik6n/typescript-starter#readme",
"repository": {
"type": "git",
Expand All @@ -23,6 +23,7 @@
"build": "rimraf ./dist && npx tsc --noEmit && node build.js",
"build:tsc": "rimraf ./dist && tsc",
"build:container": "docker build -t $npm_package_name:$npm_package_version .",
"check:container": "docker build --check .",
"dev": "tsx src/index.ts",
"dev:watch": "tsx watch src/index.ts",
"format": "prettier . --write",
Expand Down

0 comments on commit e715728

Please sign in to comment.