albert0i/dongdict
Dong Dict ─ the Online Dictionary
14
FROM mcr.microsoft.com/windows/nanoserver:20H2
ENV NODE_VERSION=18.16.1
WORKDIR /app
ENV PATH="C:\Windows\system32;C:\Windows;C:\app\node-v18.16.1-win-x64;"
# because we don't have PowerShell, we will install using CURL and TAR
# running one command reduced the size form 1.08 GB to ~765 MB on NanoServer:1903
# running on Server Core is ~ 5.61 GB
COPY package.json .env /app/
RUN curl.exe -o node-v18.16.1-win-x64.zip -L https://nodejs.org/dist/v18.16.1/node-v18.16.1-win-x64.zip && \
tar.exe -xf node-v18.16.1-win-x64.zip && \
DEL node-v18.16.1-win-x64.zip &&\
npm install
COPY src /app/src
CMD [ "node.exe", "c:\\app\\src\\app.js"]
version: "3"
services:
# app
app:
build:
context: .
image:
${IMAGE_NAME}:${IMAGE_VERSION}
container_name:
app
ports:
- 3000:3000
command:
["node.exe", "c:\\app\\src\\app.js"]
volumes:
- ${CONFIG_DIR}\data:c:\app\data
depends_on:
- redis
# redis
redis:
image:
${REDIS}
container_name:
redis
ports:
- 7000:7000
command:
["redis-server", "c:\\conf\\redis.conf"]
volumes:
- ${CONFIG_DIR}\redis\conf:c:\conf:ro
- ${CONFIG_DIR}\redis\data:c:\data\redis\data:rw
#
# Import and expose environment variables
#
cnf ?= .env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
#
# Main
#
.PHONY: help prune config my-ciapp
help:
@echo
@echo "Usage: make TARGET"
@echo
@echo "NodeJS Dockerize project automation helper for Windows version 1.0"
@echo
@echo "Targets:"
@echo " build build app image"
@echo " up start the app"
@echo " down stop the app"
@echo " ps show running containers"
@echo " logs app logs"
@echo ""
@echo " cmd start cmd on app"
@echo " config edit configuration"
#
# build app image
#
build:
docker-compose build
#
# start the app
#
up:
docker-compose up -d --remove-orphans
#
# stop the app
#
down:
docker-compose down -v
#
# show running containers
#
ps:
docker-compose ps
#
# app logs
#
logs:
docker-compose logs
#
# start cmd on app
#
cmd:
docker-compose exec app cmd
#
# edit configuration
#
config:
nano .env
#
# EOF (2024/10/18)
#
More on this git hub repository.
And live demo
docker pull albert0i/dongdict