Skip to content
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.

Commit

Permalink
add multi-arch image
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Aug 24, 2020
1 parent 6cfa6f3 commit b20ed87
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 56 deletions.
1 change: 0 additions & 1 deletion .dockerignore
@@ -1,3 +1,2 @@
.git
node_modules
examples
9 changes: 1 addition & 8 deletions Dockerfile
Expand Up @@ -2,14 +2,14 @@ FROM node:alpine
MAINTAINER silverwind

# Copy files
COPY ["node_modules", "/droppy/node_modules"]
COPY ["client", "/droppy/client"]
COPY ["server", "/droppy/server"]
COPY ["dist", "/droppy/dist"]
COPY ["droppy.js", "docker-start.sh", "README.md", "LICENSE", "package.json", "/droppy/"]

# Install build dependencies and and build modules
RUN cd /droppy && \
npm install --production --no-package-lock --no-audit --no-bin-links --ignore-scripts && \
find /droppy -type d -exec chmod 0755 {} + && \
find /droppy -type f -exec chmod 0644 {} + && \
chmod 0755 /droppy/docker-start.sh && \
Expand All @@ -19,13 +19,6 @@ RUN cd /droppy && \
ln -s /files /root/.droppy/files && \
ln -s /droppy/droppy.js /usr/bin/droppy && \
rm -rf \
/droppy/node_modules/babel-polyfill \
/droppy/node_modules/babel-runtime \
/droppy/node_modules/core-js \
/droppy/node_modules/moment/min \
/droppy/node_modules/plyr/dist/*.map \
/droppy/node_modules/plyr/src \
/droppy/node_modules/raven-js \
/root/.config \
/root/.node-gyp \
/root/.npm \
Expand Down
60 changes: 20 additions & 40 deletions Makefile
Expand Up @@ -5,6 +5,9 @@ JQUERY_FLAGS:=-ajax,-css,-deprecated,-effects,-event/alias,-event/focusin,-event
dev:
node droppy.js start --dev

run:
node droppy.js start

lint:
yarn -s run eslint server client/client.js droppy.js
yarn -s run stylelint client/*.css
Expand All @@ -21,50 +24,27 @@ publish:
npm publish

docker:
@rm -rf node_modules
yarn -s --production --pure-lockfile
$(eval IMAGE := silverwind/droppy)
@echo Preparing docker image $(IMAGE)...
docker pull node:alpine
sed -i "s/^FROM.\+/FROM node:alpine/g" Dockerfile
docker rm -f "$$(docker ps -a -f='ancestor=$(IMAGE)' -q)" 2>/dev/null || true
docker rmi "$$(docker images -qa $(IMAGE))" 2>/dev/null || true
docker build --no-cache=true --squash -t $(IMAGE) .
docker tag "$$(docker images -qa $(IMAGE):latest)" $(IMAGE):"$$(cat package.json | jq -r .version)"

$(eval IMAGE := silverwind/armhf-droppy)
@echo Preparing docker image $(IMAGE)...
docker pull arm32v6/node:alpine
sed -i "s/^FROM.\+/FROM arm32v6\/node:alpine/g" Dockerfile
docker rm -f "$$(docker ps -a -f='ancestor=$(IMAGE)' -q)" 2>/dev/null || true
docker rmi "$$(docker images -qa $(IMAGE))" 2>/dev/null || true
docker build --no-cache=true --squash -t $(IMAGE) .
docker tag "$$(docker images -qa $(IMAGE):latest)" $(IMAGE):"$$(cat package.json | jq -r .version)"

$(eval IMAGE := silverwind/arm64v8-droppy)
@echo Preparing docker image $(IMAGE)...
docker pull arm64v8/node:alpine
sed -i "s/^FROM.\+/FROM arm64v8\/node:alpine/g" Dockerfile
docker rm -f "$$(docker ps -a -f='ancestor=$(IMAGE)' -q)" 2>/dev/null || true
docker rmi "$$(docker images -qa $(IMAGE))" 2>/dev/null || true
docker build --no-cache=true --squash -t $(IMAGE) .
docker tag "$$(docker images -qa $(IMAGE):latest)" $(IMAGE):"$$(cat package.json | jq -r .version)"

sed -i "s/^FROM.\+/FROM node:alpine/g" Dockerfile

docker-push:
docker push silverwind/droppy:"$$(cat package.json | jq -r .version)"
docker push silverwind/droppy:latest
docker push silverwind/armhf-droppy:"$$(cat package.json | jq -r .version)"
docker push silverwind/armhf-droppy:latest
docker push silverwind/arm64v8-droppy:"$$(cat package.json | jq -r .version)"
docker push silverwind/arm64v8-droppy:latest
$(eval VERSION := $(shell cat package.json | jq -r .version))
$(eval ARCHS := "linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6")
@docker rm -f "$$(docker ps -a -f='ancestor=$(IMAGE)' -q)" 2>/dev/null || true
@docker rmi "$$(docker images -qa $(IMAGE))" 2>/dev/null || true
@docker buildx rm builder &>/dev/null || true
@docker buildx create --name builder &>/dev/null || true
docker buildx build --pull --push --platform $(ARCHS) -t $(IMAGE):$(VERSION) .
docker buildx build --pull --push --platform $(ARCHS) -t $(IMAGE):latest .
@docker buildx rm builder &>/dev/null || true
yarn

deps:
rm -rf node_modules
yarn

update:
yarn -s run updates -u
$(MAKE) deps
@$(MAKE) --no-print-directory deps
@touch client/client.js

jquery:
Expand All @@ -83,8 +63,8 @@ ver-minor:
ver-major:
yarn -s run versions -C major

patch: test build ver-patch docker docker-push publish
minor: test build ver-minor docker docker-push publish
major: test build ver-major docker docker-push publish
patch: test build ver-patch docker publish
minor: test build ver-minor docker publish
major: test build ver-major docker publish

.PHONY: dev lint test publish docker docker-arm deps update jquery version-patch version-minor version-major patch minor major
.PHONY: dev run lint test publish docker deps update jquery version-patch version-minor version-major patch minor major
8 changes: 1 addition & 7 deletions README.md
Expand Up @@ -52,13 +52,7 @@ To make droppy run in the background, you can use the `--daemon` option, thought

### Docker installation :whale:

The following images are available:

- [`silverwind/droppy`](https://hub.docker.com/r/silverwind/droppy/) for x86-64
- [`silverwind/armhf-droppy`](https://hub.docker.com/r/silverwind/armhf-droppy/) for ARMv6 and ARMv7
- [`silverwind/arm64v8-droppy`](https://hub.docker.com/r/silverwind/arm64v8-droppy/) for ARMv8

To pull and run, use:
The [`silverwind/droppy`](https://hub.docker.com/r/silverwind/droppy/) multi-arch images supports `amd64`, `arm64`, `arm/v7` and `arm/v6` architectures. To pull and run, use:

```sh
$ docker run --name droppy -p 127.0.0.1:8989:8989 silverwind/droppy
Expand Down

0 comments on commit b20ed87

Please sign in to comment.