mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-03-21 11:35:18 +00:00
Switch to using resin/rpi-node and node images, making use of package.json caching.
This commit is contained in:
parent
433d0bc0f0
commit
0d0ca4deda
@ -1,20 +1,44 @@
|
||||
FROM resin/i386-debian:jessie
|
||||
|
||||
# Install.
|
||||
RUN apt-get update && apt-get install -y curl git unzip wget npm nodejs inetutils-ping libsqlite3-dev socat supervisor && apt-get clean && rm -rf /var/lib/apt/lists/
|
||||
RUN ln -sf /usr/bin/nodejs /usr/bin/node
|
||||
# Nodejs
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y curl git unzip wget npm nodejs inetutils-ping \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/
|
||||
RUN ln -sf /usr/bin/nodejs /usr/bin/node
|
||||
|
||||
ADD . /app
|
||||
# Supervisor apt dependencies
|
||||
RUN apt-get -q update \
|
||||
&& apt-get install -qqy socat supervisor \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/
|
||||
|
||||
# Compile time dependencies
|
||||
RUN apt-get -q update \
|
||||
&& apt-get install -qqy g++ git libsqlite3-dev make ssh-client \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/
|
||||
|
||||
# Deploy key for private npm modules
|
||||
RUN mkdir -p /root/.ssh
|
||||
COPY deploy_key /root/.ssh/id_rsa
|
||||
COPY ssh_config /root/.ssh/config
|
||||
RUN chmod 400 /root/.ssh/*
|
||||
|
||||
# Copy supervisord launch file for resin-supervisor
|
||||
COPY resin-supervisor.conf /etc/supervisor/conf.d/resin-supervisor.conf
|
||||
|
||||
# Install dependencies
|
||||
WORKDIR /app
|
||||
COPY package.json postinstall.sh /app/
|
||||
RUN npm install --unsafe-perm --production \
|
||||
&& npm cache clean
|
||||
|
||||
# Copy source
|
||||
COPY . /app/
|
||||
|
||||
ENV SUPERVISOR_IMAGE resin/i386-supervisor
|
||||
ENV CONFIG_MOUNT_POINT /boot/config.json
|
||||
ENV LED_FILE /dev/null
|
||||
|
||||
RUN rm -rf node_modules
|
||||
RUN npm install --unsafe-perm --production
|
||||
|
||||
RUN ln -sf /app/entry.sh /start
|
||||
|
||||
CMD ["/app/entry.sh"]
|
||||
|
@ -1,4 +1,36 @@
|
||||
FROM resin/supervisor-base:latest
|
||||
ADD . /app
|
||||
RUN /build/builder
|
||||
RUN apt-get clean
|
||||
FROM resin/rpi-node:0.10.36-slim
|
||||
|
||||
# Supervisor apt dependencies
|
||||
RUN apt-get -q update \
|
||||
&& apt-get install -qqy socat supervisor \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/
|
||||
|
||||
# Compile time dependencies
|
||||
RUN apt-get -q update \
|
||||
&& apt-get install -qqy g++ git libsqlite3-dev make ssh-client \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/
|
||||
|
||||
# Deploy key for private npm modules
|
||||
RUN mkdir -p /root/.ssh
|
||||
COPY deploy_key /root/.ssh/id_rsa
|
||||
COPY ssh_config /root/.ssh/config
|
||||
RUN chmod 400 /root/.ssh/*
|
||||
|
||||
# Copy supervisord launch file for resin-supervisor
|
||||
COPY resin-supervisor.conf /etc/supervisor/conf.d/resin-supervisor.conf
|
||||
|
||||
# Install dependencies
|
||||
WORKDIR /app
|
||||
COPY package.json postinstall.sh /app/
|
||||
RUN npm install --unsafe-perm --production \
|
||||
&& npm cache clean
|
||||
|
||||
# Copy source
|
||||
COPY . /app/
|
||||
|
||||
RUN chmod +x /app/src/enterContainer.sh
|
||||
RUN /app/node_modules/.bin/coffee -c /app/src
|
||||
|
||||
CMD ["/app/entry.sh"]
|
||||
|
@ -1,20 +1,37 @@
|
||||
FROM dockerfile/nodejs
|
||||
FROM node:0.10.36-slim
|
||||
|
||||
RUN apt-get -q update && apt-get install -qqy libsqlite3-dev socat supervisor
|
||||
# Supervisor apt dependencies
|
||||
RUN apt-get -q update \
|
||||
&& apt-get install -qqy socat supervisor \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/
|
||||
|
||||
ADD . /app
|
||||
# Compile time dependencies
|
||||
RUN apt-get -q update \
|
||||
&& apt-get install -qqy g++ git libsqlite3-dev make ssh-client \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/
|
||||
|
||||
# Deploy key for private npm modules
|
||||
RUN mkdir -p /root/.ssh
|
||||
COPY deploy_key /root/.ssh/id_rsa
|
||||
COPY ssh_config /root/.ssh/config
|
||||
RUN chmod 400 /root/.ssh/*
|
||||
|
||||
# Copy supervisord launch file for resin-supervisor
|
||||
COPY resin-supervisor.conf /etc/supervisor/conf.d/resin-supervisor.conf
|
||||
|
||||
# Install dependencies
|
||||
WORKDIR /app
|
||||
COPY package.json postinstall.sh /app/
|
||||
RUN npm install --unsafe-perm --production \
|
||||
&& npm cache clean
|
||||
|
||||
# Copy source
|
||||
COPY . /app/
|
||||
|
||||
ENV SUPERVISOR_IMAGE resin/x86_64-supervisor
|
||||
ENV CONFIG_MOUNT_POINT /boot/config.json
|
||||
ENV LED_FILE /dev/null
|
||||
|
||||
RUN rm -rf node_modules
|
||||
RUN npm install --unsafe-perm --production
|
||||
|
||||
RUN ln -sf /app/entry.sh /start
|
||||
|
||||
RUN apt-get clean
|
||||
|
||||
CMD ["/app/entry.sh"]
|
||||
|
2
Makefile
2
Makefile
@ -45,7 +45,7 @@ endif
|
||||
docker tag -f resin/supervisor-base:$(BUILDSTEP_VERSION) resin/supervisor-base:latest
|
||||
endif
|
||||
|
||||
supervisor: supervisor-base
|
||||
supervisor:
|
||||
cp Dockerfile.$(ARCH) Dockerfile
|
||||
echo "ENV VERSION "`jq -r .version package.json` >> Dockerfile
|
||||
docker build --no-cache=$(DISABLE_CACHE) -t resin/$(ARCH)-supervisor:$(SUPERVISOR_VERSION) .
|
||||
|
10
deps.sh
10
deps.sh
@ -1,10 +0,0 @@
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
if [ $NODE_ENV == 'production' ]; then
|
||||
# Deploy key for private npm modules
|
||||
mkdir -p /root/.ssh
|
||||
cp deploy_key /root/.ssh/id_rsa
|
||||
chmod 400 /root/.ssh/id_rsa
|
||||
cp ssh_config /root/.ssh/config
|
||||
fi
|
@ -2,7 +2,6 @@
|
||||
"name": "resin-supervisor",
|
||||
"version": "0.0.5",
|
||||
"scripts": {
|
||||
"preinstall": "bash deps.sh",
|
||||
"postinstall": "bash postinstall.sh",
|
||||
"start": "./entry.sh"
|
||||
},
|
||||
|
@ -1,24 +1,7 @@
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
# Copy supervisord launch file for resin-supervisor
|
||||
cp /app/resin-supervisor.conf /etc/supervisor/conf.d/resin-supervisor.conf
|
||||
|
||||
if [ $NODE_ENV == 'production' ]; then
|
||||
chmod +x src/enterContainer.sh
|
||||
|
||||
node ./node_modules/coffee-script/bin/coffee -c ./src
|
||||
# We don't need coffee-script at runtime
|
||||
npm uninstall coffee-script
|
||||
# Empty the apt and npm caches of the packages we installed
|
||||
npm cache clean
|
||||
apt-get clean
|
||||
# Remove deploy key
|
||||
rm -rf /root/.ssh/* deploy_key
|
||||
# Remove unnecessary source files
|
||||
rm -rf Makefile src/*.coffee
|
||||
# Remove the git repo info
|
||||
rm -rf .git
|
||||
if [[ $NODE_ENV == 'production' ]]; then
|
||||
# Remove the c files we no longer need (the sqlite3 node module has a massive ~5M c file)
|
||||
find . -name '*.c' -delete
|
||||
# And the tar files (sqlite3 module again)
|
||||
@ -30,6 +13,4 @@ if [ $NODE_ENV == 'production' ]; then
|
||||
# And any benchmark results (ttyjs->socket.io->socket.io-client->active-x-obfuscator->zeparser has an 8MB benchmark.html)
|
||||
find . -type d -name 'benchmark*' -exec rm -rf '{}' \; 2> /dev/null || true
|
||||
find . -name 'benchmark*' -delete
|
||||
# And npm - we've finished with it
|
||||
find . -type d -name 'npm' -exec rm -rf '{}' \; 2> /dev/null || true
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user