Skip to content

Instantly share code, notes, and snippets.

@ifiok
ifiok / docker node dockerfile
Created December 30, 2019 15:03 — forked from victory1908/docker node dockerfile
docker node #docker
I took one of my current projects and basically ran your Dockerfile...and got a 1.1 GB docker save tar file. It compresses well, but a 345 MB gzipped tar file still isn't what you're after. "Use an Alpine base image" is somewhat helpful, but not a silver bullet; switching it to be FROM node:8-alpine reduces it to a 514 MB uncompressed tar file.
If you don't already have a .dockerignore file, then your entire existing node_modules directory will get copied into the image. (In particular, the COPY . . step will copy your entire working tree in, overwriting the installed modules from the previous step.) It can just contain the single line
node_modules
The Alpine base image, plus not emitting a duplicate node_modules tree, gets me down to 382 MB uncompressed.
Notice in your example that your npm install step includes all of the development dependencies as well as the runtime dependencies. That can be a significant cost. If your application doesn't need any precompilation (it is plain JavaScript that Node can r
@ifiok
ifiok / Jenkinsfile
Created April 6, 2019 22:49 — forked from robertstettner/Jenkinsfile
Example Jenkinsfile
pipeline {
stages {
stage("install") {
agent {
docker {
reuseNode true
image 'node:6.10'
}
}
steps {
@ifiok
ifiok / ssm.sh
Last active July 27, 2023 16:10
Shell script for getting variables from AWS Parameter Store and creating a .env file for environment variables
# Add environment variables to AWS Parameter Store on the same path prefix for the same project
# To get the environment variables for a project, get the variables by path
# Convert it to a .env file format
# env1=abc
# env2=def
# separated by the newline character
# and write to a .env file
myService=/myservice_name/stage_name
# Get variables from SSM and chop off the service name from the variable names (/myservice_name/stage_name/PORT to PORT) and write to a JSON file
@ifiok
ifiok / gotham.md
Created August 21, 2018 08:32 — forked from mfd/ gotham.md
Gotham font
https://cdn.rawgit.com/mfd/f3d96ec7f0e8f034cc22ea73b3797b59/raw/856f1dbb8d807aabceb80b6d4f94b464df461b3e/gotham.css

<link rel="https://cdn.rawgit.com/mfd/f3d96ec7f0e8f034cc22ea73b3797b59/raw/856f1dbb8d807aabceb80b6d4f94b464df461b3e/gotham.css">

@ifiok
ifiok / docker_output.py
Created July 31, 2018 12:52
Docker Python logger output to stdout
import logging
from sys import stdout
# Define logger
logger = logging.getLogger('mylogger')
logger.setLevel(logging.DEBUG) # set logger level
logFormatter = logging.Formatter\
("%(name)-12s %(asctime)s %(levelname)-8s %(filename)s:%(funcName)s %(message)s")
consoleHandler = logging.StreamHandler(stdout) #set streamhandler to stdout
@ifiok
ifiok / Dockerfile
Last active July 26, 2018 13:31
Dockerfile for Python 3 using pipenv and supervisor
ARG PYTHON_VERSION=3.7
ARG ALPINE_VERSION=3.7
FROM python:${PYTHON_VERSION}-alpine${ALPINE_VERSION}
WORKDIR /app
COPY supervisord.conf /etc/
COPY . /app
ENV LC_ALL C.UTF-8