NodeJS App and Docker

NodeJSAppandDocker

1DockerfiletoInstalltheEnvandApp

#RunaSimpleRESTAPIbasedonplayframework

#PrepretheOS

FROMcentos:7

MAINTAINERCarlLuo<[email protected]>

ENVDEBIAN_FRONTENDnoninteractive

ENVHTTP_PORT8004

#InstallnodeJSandforeverJS

RUNyumgroupinstall-y"DevelopmentTools"

RUNmkdir/tool/

WORKDIR/tool/

ADDinstall/node-v4.2.3.tar.gz/tool/

WORKDIR/tool/node-v4.2.3

RUN./configure

RUNmake

RUNmakeinstall

RUNnpminstall-gforever

#InstalltheApplication

RUNmkdir-p/share/email-scan

WORKDIR/share/email-scan

ADD/dist/email-scan-1.0.tar.gz/share/email-scan

#StarttheApplication

EXPOSE8004

RUNmkdir-p/app/

ADDstart.sh/app/

WORKDIR/app

CMD["./start.sh"]

2StartCommandstart.sh

#!/bin/sh-ex

cd/share/email-scan

PORT=8004foreverstart--minUptime10000--spinSleepTime10000-a-lforever.log-o./logs/out.log-e./logs/err.logapp.js

tail-f/dev/null

Thelastcommandtail-f/dev/nullisimportant,thatwillkeepthecontainerrunning.

3MakefileforRun/Debug/Build

IMAGE=sillycat/email-scan

TAG=1.0

NAME=email-scan

REPOSITORY=registry.sillycat.com

prepare:

wgethttps://nodejs.org/dist/v4.2.3/node-v4.2.3.tar.gz-Pinstall/

push-local:

dockerpush$(REPOSITORY)/$(IMAGE):$(TAG)

app-build:

gulpdist

docker-context:

build:docker-context

dockerbuild-t$(REPOSITORY)/$(IMAGE):$(TAG).

run-stage:

dockerrun-d-p8004:8004-eRUNNING_ENV=stage--name$(NAME)$(REPOSITORY)/$(IMAGE):$(TAG)

debug:

dockerrun-ti-p8004:8004--name$(NAME)$(REPOSITORY)/$(IMAGE):$(TAG)/bin/bash

clean:

dockerstop${NAME}

dockerrm${NAME}

logs:

dockerlogs${NAME}

publish:

dockerpush${IMAGE}

References:

相关推荐