mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-18 21:27:51 +00:00
docker: Add Docker images with the CLI and Docker-in-Docker
Add Dockerfiles for alpine and debian images, based on balenalib/arch-distro-node images. Change-type: minor Signed-off-by: Kyle Harding <kyle@balena.io>
This commit is contained in:
parent
23165806aa
commit
65d5bdff08
37
.dockerignore
Normal file
37
.dockerignore
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# Reminders:
|
||||||
|
# * Matching rules are different to `.gitignore`
|
||||||
|
# * A pattern without '**' matches in the project's root directory only
|
||||||
|
# * Leading and trailing '/' are discarded (it is not possible to
|
||||||
|
# distinguish between files and directories)
|
||||||
|
# * More details: https://github.com/balena-io-modules/dockerignore
|
||||||
|
|
||||||
|
# development and testing tools or IDEs
|
||||||
|
**/*.log
|
||||||
|
**/*.pid
|
||||||
|
**/*.seed
|
||||||
|
.idea
|
||||||
|
.lock-wscript
|
||||||
|
.nvmrc
|
||||||
|
.nyc_output
|
||||||
|
.vscode
|
||||||
|
coverage
|
||||||
|
lib-cov
|
||||||
|
logs
|
||||||
|
pids
|
||||||
|
|
||||||
|
# OS cache files
|
||||||
|
**/.DS_Store
|
||||||
|
|
||||||
|
# balena CLI config and build files
|
||||||
|
**/.balenaconf
|
||||||
|
**/.fast-boot.json
|
||||||
|
**/.resinconf
|
||||||
|
balenarc.yml
|
||||||
|
build
|
||||||
|
build-bin
|
||||||
|
dist
|
||||||
|
node_modules
|
||||||
|
oclif.manifest.json
|
||||||
|
package-lock.json
|
||||||
|
resinrc.yml
|
||||||
|
tmp
|
69
.gitignore
vendored
69
.gitignore
vendored
@ -1,47 +1,36 @@
|
|||||||
# Logs
|
# Reminders:
|
||||||
logs
|
# * A pattern without '/' matches in subdirectories as well (files and directories)
|
||||||
*.log
|
# * A leading '/' anchors matching to the directory where `.gitignore` is defined
|
||||||
|
# * A trailing '/' makes the pattern match against directories only
|
||||||
|
# More details: https://git-scm.com/docs/gitignore
|
||||||
|
|
||||||
# Runtime data
|
# development and testing tools or IDEs
|
||||||
pids
|
*.log
|
||||||
*.pid
|
*.pid
|
||||||
*.seed
|
*.seed
|
||||||
|
/.idea/
|
||||||
|
/.lock-wscript
|
||||||
|
/.nvmrc
|
||||||
|
/.nyc_output/
|
||||||
|
/.vscode/
|
||||||
|
/coverage/
|
||||||
|
/lib-cov/
|
||||||
|
/logs
|
||||||
|
/pids
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
# OS cache files
|
||||||
lib-cov
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
|
||||||
coverage
|
|
||||||
.nyc_output
|
|
||||||
|
|
||||||
# node-waf configuration
|
|
||||||
.lock-wscript
|
|
||||||
|
|
||||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
|
||||||
build/Release
|
|
||||||
|
|
||||||
# Dependency directory
|
|
||||||
# Commenting this out is preferred by some people, see
|
|
||||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
|
|
||||||
node_modules
|
|
||||||
|
|
||||||
package-lock.json
|
|
||||||
.resinconf
|
|
||||||
.balenaconf
|
|
||||||
resinrc.yml
|
|
||||||
balenarc.yml
|
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.idea
|
|
||||||
.nvmrc
|
|
||||||
.vscode
|
|
||||||
|
|
||||||
/tmp
|
# balena CLI config and build files
|
||||||
build/
|
.balenaconf
|
||||||
build-bin/
|
.fast-boot.json
|
||||||
build-zip/
|
.resinconf
|
||||||
dist/
|
/balenarc.yml
|
||||||
|
/build/
|
||||||
# Ignore fast-boot cache file
|
/build-bin/
|
||||||
**/.fast-boot.json
|
/dist/
|
||||||
|
/node_modules
|
||||||
/oclif.manifest.json
|
/oclif.manifest.json
|
||||||
|
/package-lock.json
|
||||||
|
/resinrc.yml
|
||||||
|
/tmp/
|
||||||
|
73
.resinci.yml
73
.resinci.yml
@ -17,4 +17,75 @@ npm:
|
|||||||
- "14"
|
- "14"
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
publish: false
|
builds:
|
||||||
|
- path: .
|
||||||
|
dockerfile: ./docker/alpine/Dockerfile
|
||||||
|
docker_repo: balenalib/amd64-alpine-balenacli
|
||||||
|
args:
|
||||||
|
- BUILD_BASE=balenalib/amd64-alpine-node:12.19.1-build-20201211
|
||||||
|
- RUN_BASE=balenalib/amd64-alpine-node:12.19.1-run-20201211
|
||||||
|
publish: true
|
||||||
|
|
||||||
|
- path: .
|
||||||
|
dockerfile: ./docker/alpine/Dockerfile
|
||||||
|
docker_repo: balenalib/armv7hf-alpine-balenacli
|
||||||
|
args:
|
||||||
|
- BUILD_BASE=balenalib/armv7hf-alpine-node:12.19.1-build-20201211
|
||||||
|
- RUN_BASE=balenalib/armv7hf-alpine-node:12.19.1-run-20201211
|
||||||
|
publish: true
|
||||||
|
|
||||||
|
- path: .
|
||||||
|
dockerfile: ./docker/alpine/Dockerfile
|
||||||
|
docker_repo: balenalib/i386-alpine-balenacli
|
||||||
|
args:
|
||||||
|
- BUILD_BASE=balenalib/i386-alpine-node:12.19.1-build-20201211
|
||||||
|
- RUN_BASE=balenalib/i386-alpine-node:12.19.1-run-20201211
|
||||||
|
publish: true
|
||||||
|
|
||||||
|
- path: .
|
||||||
|
dockerfile: ./docker/alpine/Dockerfile
|
||||||
|
docker_repo: balenalib/rpi-alpine-balenacli
|
||||||
|
args:
|
||||||
|
- BUILD_BASE=balenalib/rpi-alpine-node:12.19.1-build-20201211
|
||||||
|
- RUN_BASE=balenalib/rpi-alpine-node:12.19.1-run-20201211
|
||||||
|
publish: true
|
||||||
|
|
||||||
|
- path: .
|
||||||
|
dockerfile: ./docker/debian/Dockerfile
|
||||||
|
docker_repo: balenalib/aarch64-debian-balenacli
|
||||||
|
args:
|
||||||
|
- BUILD_BASE=balenalib/aarch64-debian-node:12.19.1-build-20201118
|
||||||
|
- RUN_BASE=balenalib/aarch64-debian-node:12.19.1-run-20201118
|
||||||
|
publish: true
|
||||||
|
|
||||||
|
- path: .
|
||||||
|
dockerfile: ./docker/debian/Dockerfile
|
||||||
|
docker_repo: balenalib/amd64-debian-balenacli
|
||||||
|
args:
|
||||||
|
- BUILD_BASE=balenalib/amd64-debian-node:12.19.1-build-20201211
|
||||||
|
- RUN_BASE=balenalib/amd64-debian-node:12.19.1-run-20201211
|
||||||
|
publish: true
|
||||||
|
|
||||||
|
- path: .
|
||||||
|
dockerfile: ./docker/debian/Dockerfile
|
||||||
|
docker_repo: balenalib/armv7hf-debian-balenacli
|
||||||
|
args:
|
||||||
|
- BUILD_BASE=balenalib/armv7hf-debian-node:12.19.1-build-20201211
|
||||||
|
- RUN_BASE=balenalib/armv7hf-debian-node:12.19.1-run-20201211
|
||||||
|
publish: true
|
||||||
|
|
||||||
|
- path: .
|
||||||
|
dockerfile: ./docker/debian/Dockerfile
|
||||||
|
docker_repo: balenalib/i386-debian-balenacli
|
||||||
|
args:
|
||||||
|
- BUILD_BASE=balenalib/i386-debian-node:12.16.3-build-20200518
|
||||||
|
- RUN_BASE=balenalib/i386-debian-node:12.16.3-build-20200518
|
||||||
|
publish: true
|
||||||
|
|
||||||
|
- path: .
|
||||||
|
dockerfile: ./docker/debian/Dockerfile
|
||||||
|
docker_repo: balenalib/rpi-debian-balenacli
|
||||||
|
args:
|
||||||
|
- BUILD_BASE=balenalib/rpi-debian-node:12.19.1-build-20201211
|
||||||
|
- RUN_BASE=balenalib/rpi-debian-node:12.19.1-run-20201211
|
||||||
|
publish: true
|
||||||
|
43
docker/alpine/Dockerfile
Normal file
43
docker/alpine/Dockerfile
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
ARG BUILD_BASE=balenalib/amd64-alpine-node:12.19.1-build
|
||||||
|
ARG RUN_BASE=balenalib/amd64-alpine-node:12.19.1-run
|
||||||
|
|
||||||
|
FROM ${BUILD_BASE} as build
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# dev dependencies are required for build:fast
|
||||||
|
# --unsafe-perm is not needed because of global /usr/local/etc/npmrc
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
RUN npm run build:fast
|
||||||
|
|
||||||
|
# remove dev dependencies after build:fast
|
||||||
|
RUN npm prune --production
|
||||||
|
|
||||||
|
FROM ${RUN_BASE}
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
COPY --from=build /usr/src/app/ .
|
||||||
|
|
||||||
|
ENV PATH $PATH:/usr/src/app/bin
|
||||||
|
|
||||||
|
# fail early if balena binary won't run
|
||||||
|
RUN balena --version
|
||||||
|
|
||||||
|
# https://github.com/balena-io/balena-cli/blob/master/INSTALL-LINUX.md#additional-dependencies
|
||||||
|
RUN install_packages avahi bash ca-certificates docker jq openssh
|
||||||
|
|
||||||
|
COPY docker/docker-init.sh init.sh
|
||||||
|
|
||||||
|
RUN CLI_CMDS=$(jq -r '.commands | keys | map(.[0:index(":")]) | unique | join("\\ ")' < oclif.manifest.json); \
|
||||||
|
sed -ie "s/CLI_CMDS=\"help\"/CLI_CMDS=\"help\\ ${CLI_CMDS}\"/" init.sh && \
|
||||||
|
chmod +x init.sh
|
||||||
|
|
||||||
|
ENTRYPOINT [ "./init.sh" ]
|
||||||
|
|
||||||
|
CMD [ "help" ]
|
||||||
|
|
||||||
|
ENV SSH_AUTH_SOCK "/ssh-agent"
|
43
docker/debian/Dockerfile
Normal file
43
docker/debian/Dockerfile
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
ARG BUILD_BASE=balenalib/amd64-debian-node:12.19.1-build
|
||||||
|
ARG RUN_BASE=balenalib/amd64-debian-node:12.19.1-run
|
||||||
|
|
||||||
|
FROM ${BUILD_BASE} as build
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# dev dependencies are required for build:fast
|
||||||
|
# --unsafe-perm is not needed because of global /usr/local/etc/npmrc
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
RUN npm run build:fast
|
||||||
|
|
||||||
|
# remove dev dependencies after build:fast
|
||||||
|
RUN npm prune --production
|
||||||
|
|
||||||
|
FROM ${RUN_BASE}
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
COPY --from=build /usr/src/app/ .
|
||||||
|
|
||||||
|
ENV PATH $PATH:/usr/src/app/bin
|
||||||
|
|
||||||
|
# fail early if balena binary won't run
|
||||||
|
RUN balena --version
|
||||||
|
|
||||||
|
# https://github.com/balena-io/balena-cli/blob/master/INSTALL-LINUX.md#additional-dependencies
|
||||||
|
RUN install_packages avahi-daemon ca-certificates docker.io jq openssh-client
|
||||||
|
|
||||||
|
COPY docker/docker-init.sh init.sh
|
||||||
|
|
||||||
|
RUN CLI_CMDS=$(jq -r '.commands | keys | map(.[0:index(":")]) | unique | join("\\ ")' < oclif.manifest.json); \
|
||||||
|
sed -ie "s/CLI_CMDS=\"help\"/CLI_CMDS=\"help\\ ${CLI_CMDS}\"/" init.sh && \
|
||||||
|
chmod +x init.sh
|
||||||
|
|
||||||
|
ENTRYPOINT [ "./init.sh" ]
|
||||||
|
|
||||||
|
CMD [ "help" ]
|
||||||
|
|
||||||
|
ENV SSH_AUTH_SOCK "/ssh-agent"
|
30
docker/docker-init.sh
Normal file
30
docker/docker-init.sh
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# start dockerd if env var is set
|
||||||
|
if [ "${DOCKERD}" = "1" ]
|
||||||
|
then
|
||||||
|
[ -e /var/run/docker.sock ] && rm /var/run/docker.sock
|
||||||
|
dockerd &
|
||||||
|
fi
|
||||||
|
|
||||||
|
# load private ssh key if one is provided
|
||||||
|
if [ -n "${SSH_PRIVATE_KEY}" ]
|
||||||
|
then
|
||||||
|
# if an ssh agent socket was not provided, start our own agent
|
||||||
|
[ -e "${SSH_AUTH_SOCK}" ] || eval "$(ssh-agent -s)"
|
||||||
|
echo "${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add -
|
||||||
|
fi
|
||||||
|
|
||||||
|
# space-separated list of balena CLI commands (filled in through `sed`
|
||||||
|
# in a Dockerfile RUN instruction)
|
||||||
|
CLI_CMDS="help"
|
||||||
|
|
||||||
|
# treat the provided command as a balena CLI arg...
|
||||||
|
# 1. if the first word matches a known entry in CLI_CMDS
|
||||||
|
# 2. OR if the first character is a hyphen (eg. -h or --debug)
|
||||||
|
if [[ " ${CLI_CMDS} " =~ " ${1} " ]] || [ "${1:0:1}" = "-" ]
|
||||||
|
then
|
||||||
|
exec balena "$@"
|
||||||
|
else
|
||||||
|
exec "$@"
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user