Skip to content

Instantly share code, notes, and snippets.

@RodolpheGohard
Created March 29, 2022 15:01
Show Gist options
  • Save RodolpheGohard/fbff6566a2561d4f393382e5481b60f3 to your computer and use it in GitHub Desktop.
Save RodolpheGohard/fbff6566a2561d4f393382e5481b60f3 to your computer and use it in GitHub Desktop.
My dev in docker config
#!/usr/bin/env bash
export IMAGE_NAME=dev-node-in-docker
export SWAN_HOME=/home/rodolphe/dev/swan.io
docker build -t ${IMAGE_NAME} .
if [ ! -e "./.aws/credentials" ]; then
cp ./.aws/credentials.sample ./.aws/credentials
fi
export CONTAINER_WORKDIR=/home
docker run -it \
--network host \
-v webhooks-npm:/home/npm \
-v ${SWAN_HOME}/graphql/:$CONTAINER_WORKDIR/graphql \
-v ${SWAN_HOME}/webhook/:$CONTAINER_WORKDIR/webhook \
-v ${SWAN_HOME}/billing-api/:$CONTAINER_WORKDIR/billing-api \
-v /home/rodolphe/.gitconfig:$CONTAINER_WORKDIR/.gitconfig \
-v ${SWAN_HOME}/webhook/dev-in-docker/.aws:$CONTAINER_WORKDIR/.aws \
-v ${SWAN_HOME}/webhook/.npmrc:$CONTAINER_WORKDIR/.npmrc \
${IMAGE_NAME} \
bash
FROM node:14.17.3-slim
# Dependencies
RUN apt update && apt -y install curl less unzip git vim procps && apt clean
# Installing AWS client, https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html#cliv2-linux-install
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.2.38.zip" -o "awscliv2.zip" && unzip awscliv2.zip && ./aws/install
# AWS config
COPY .aws /root/.aws
# Setting NPM prefix in a volume for persistence
ENV NPM_CONFIG_PREFIX=/home/npm
ENV YARN_CACHE_FOLDER=/home/npm/yarn.cache
VOLUME /home/npm
# Nice things
COPY intputrc /etc/inputrc
# Home and user config
RUN chown node:node /home
RUN usermod -d /home node
USER node:node
ENV PATH "$PATH:$NPM_CONFIG_PREFIX/bin"
WORKDIR home
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment