Deploying Marvin, part 2
• Mark Eschbach
Alrighty, we left off with a failure due to Node and friends not being on the path. I’ve had to install version 8.4.0 for this project which is easy enough. First run after ensuring it’s on the path passed wihtout a problem. Next step is the deployment process itself.
Deployment
This will require another Jenkins job. In the future I think I’ll want to check out the Pipelines because they look cool but for now I’m just going to stick with what I know. Trying not to shave more yaks than I need too :-).
I’m sticking with my current tradition, putting the script in .ci/deploy/hook
. The hook essentially does the following at this stage:
- Build the container
- Stop the old instance of the application
- Start new instance of the application
For this application I’m lucky enough to get away with using striaght Node, so I’m building the container from the 8.4.0-alpine
base. A simple Dockerfile for it:
FROM node:8.4.0-alpine
RUN mkdir -p /app
# -D = no password
# -h = home directory
RUN adduser -h /app -D app
ADD . /app
WORKDIR /app
RUN chown -R app:app /app
USER app
RUN npm install
CMD ["node", "service.js"]
And a simple .dockerignore
file!
node_modules
.git
Alrighty, I’m having the script stop the old instance for right now, which is fine. I’m really missing the orchestration software on ECS now. I guess they add quiet a bit of value. In the future I’ll have to build out something similar but smaller. Or find someone else who has built something similar and lightweight.
Bingo, app deployed.