Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dockerfile with new build #9

Open
wants to merge 1 commit into
base: master-2.2.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 112 additions & 85 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,85 +1,112 @@
FROM node:4-onbuild

################
# App Deps #
################

RUN mkdir /app
WORKDIR /app
LABEL maintainer="Aharon Rubin <[email protected]>"

# TODO:
# Copy over your application stuff required to load up
# dependencies and then install those dependencies

ADD package.json /app/package.json
RUN npm install -d
RUN npm install -g coffee-script

## INSTALL DEPENDENCIES
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
wget \
lsof \
vim \
git \
less \
iputils-ping \
net-tools \
dnsutils \
iftop \
htop \
nethogs \
traceroute \
python3-dev \
python3-pip \
unzip\
libyaml-dev \
&& rm -rf /var/lib/apt/lists/*

## BUILD PYTHON-CONSUL
RUN pip3 install setuptools wheel python-consul

################
# App Source #
################

# Copy over your apps sourcecode in this section
COPY . /app/

################
# Container Pilot #
################


# Install ContainerPilot
ENV CONTAINERPILOT_VERSION 3.4.2
RUN export CP_SHA1=5c99ae9ede01e8fcb9b027b5b3cb0cfd8c0b8b88 \
&& curl -Lso /tmp/containerpilot.tar.gz \
"https://github.com/joyent/containerpilot/releases/download/${CONTAINERPILOT_VERSION}/containerpilot-${CONTAINERPILOT_VERSION}.tar.gz" \
&& echo "${CP_SHA1} /tmp/containerpilot.tar.gz" | sha1sum -c \
&& tar zxf /tmp/containerpilot.tar.gz -C /bin \
&& rm /tmp/containerpilot.tar.gz

#Install envconsul
RUN wget https://releases.hashicorp.com/envconsul/0.6.1/envconsul_0.6.1_linux_amd64.zip&&unzip envconsul_0.6.1_linux_amd64.zip\
&& ln -sf $PWD/envconsul /usr/local/bin

# COPY ContainerPilot configuration
ENV CONTAINERPILOT_PATH=/etc/containerpilot.json5
COPY devops/containerpilot.json5 ${CONTAINERPILOT_PATH}
ENV CONTAINERPILOT=${CONTAINERPILOT_PATH}


#############
# Conclude #
#############


COPY entrypoint.sh /sbin/entrypoint.sh
RUN chmod +x /sbin/entrypoint.sh
RUN chmod +x devops/entrypoint.sh
RUN echo ". /sbin/entrypoint.sh" > /root/.bash_history

#ENTRYPOINT ["/sbin/entrypoint.sh"]
ENTRYPOINT ["/bin/containerpilot"]
FROM node:12.16.0-alpine as base

LABEL maintainer "Igal Dahan <[email protected]>"

RUN apk update \
&& apk add --no-cache \
ca-certificates curl wget lsof \
vim git less busybox-extras \
net-tools iftop htop nethogs \
unzip wget python gcc \
libc-dev bash make g++

# This is the release of Consul to pull in.
ENV CONSUL_VERSION=1.4.3

# This is the location of the releases.
ENV HASHICORP_RELEASES=https://releases.hashicorp.com

# Add consul agent
RUN export CONSUL_VERSION=1.4.3 \
&& wget "https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip" \
&& unzip $PWD/consul_${CONSUL_VERSION}_linux_amd64.zip -d /usr/local/bin \
&& rm /$PWD/consul_${CONSUL_VERSION}_linux_amd64.zip

#&& export CONSUL_CHECKSUM=8806fdaace8cfca3a0d49a2ef1ea03e5d2b63ff1f3fbe9909dc190637195df5c \
#&& curl --retry 7 --fail -vo /tmp/consul.zip "https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip" \
#&& echo "${CONSUL_CHECKSUM} /tmp/consul.zip" | sha256sum -c \

# INSTALL GOSU
#ENV GOSU_VERSION 1.11
#RUN dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
# wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
# wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
# \
# # verify the signature
# export GNUPGHOME="$(mktemp -d)"; \
# # for flaky keyservers, consider https://github.com/tianon/pgp-happy-eyeballs, ala https://github.com/docker-library/php/pull/666
# gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
# gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
# command -v gpgconf && gpgconf --kill all || :; \
# rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
# \
# chmod +x /usr/local/bin/gosu; \
# # verify that the binary works
# gosu --version; \
# gosu nobody true

# Install envconsul
RUN wget https://releases.hashicorp.com/envconsul/0.6.1/envconsul_0.6.1_linux_amd64.zip \
&& unzip envconsul_0.6.1_linux_amd64.zip \
&& rm envconsul_0.6.1_linux_amd64.zip \
&& mv $PWD/envconsul /usr/local/bin

ENV DOCKERIZE_VERSION v0.6.1
RUN wget https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz \
&& rm dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz


COPY package.json .

## ---- Dependencies ----
FROM base AS dependencies
# install node packages

## Copy Artifact certificate for login
COPY .npmrc /.npmrc

# Copy source code into the container
COPY --chown=node ./ ./source-code
WORKDIR ./source-code

RUN npm config set registry https://anyvision.jfrog.io/anyvision/api/npm/npm/
RUN PYTHON=/usr/bin/python
RUN npm ci --verbose
RUN npm run build
# Delete the unneeded src folder
# RUN rm -rf ./src
# Use npm ci to delete the old node_modules and install only production
RUN npm --verbose ci --production
RUN rm .npmrc

# ---- Release ----
FROM node:12.16.0-alpine AS release

RUN apk update \
&& apk add --no-cache \
curl su-exec\
vim git less busybox-extras \
net-tools iftop htop nethogs \
unzip wget \
bash

# INSTALL NODE MODULES
ENV APP_DIR /home/node/RENAMEIT
WORKDIR $APP_DIR

RUN chown node:node /home/node/RENAMEIT
#COPY --from=base /usr/local/bin/gosu /usr/local/bin/gosu
COPY --from=base /usr/local/bin/envconsul /usr/local/bin/envconsul
COPY --from=base /usr/local/bin/dockerize /usr/local/bin/dockerize
COPY --from=base /usr/local/bin/consul /usr/local/bin/consul
# COPY all needed resources from previous layer (dist, swagger, node_modules (Production modules only)
COPY --from=dependencies --chown=node /source-code/ /home/node/RENAMEIT/
COPY docker-entrypoint.sh /

RUN chmod u+x /docker-entrypoint.sh


ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["npm","start"]