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

[FEATURE] RPi Arm V7 & 8 Docker support revisited #130

Merged
merged 2 commits into from
Aug 7, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM node:lts-alpine

# Define some ENV Vars
ENV PORT 80
ENV DIRECTORY /app
ENV IS_DOCKER true
ENV PORT=80 \
DIRECTORY=/app \
IS_DOCKER=true

# Create and set the working directory
WORKDIR ${DIRECTORY}
Expand Down
43 changes: 43 additions & 0 deletions Dockerfile-arm32v7
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM alpine:3.12 AS builder

# Download QEMU, see https://github.com/docker/hub-feedback/issues/1261
RUN QEMU_URL=https://github.com/balena-io/qemu/releases/download/v5.2.0%2Bbalena4/qemu-5.2.0.balena4-arm.tar.gz \
&& apk add curl && curl -L $QEMU_URL | tar zxvf - -C . --strip-components 1

# Start second (arm32v7) stage
FROM arm32v7/alpine:3.12

# Add QEMU from build stage
COPY --from=builder qemu-arm-static /usr/bin

# Install Node and Yarn
RUN apk add --update --no-cache nodejs npm yarn

# Define some ENV Vars
ENV PORT=80 \
DIRECTORY=/app \
IS_DOCKER=true

# Create and set the working directory
WORKDIR ${DIRECTORY}

# Copy over both 'package.json' and 'package-lock.json' (if available)
COPY package*.json ./

# Install project dependencies
RUN yarn

# Copy over all project files and folders to the working directory
COPY . .

# Build initial app for production
RUN yarn build

# Expose given port
EXPOSE ${PORT}

# Finally, run start command to serve up the built application
CMD [ "yarn", "build-and-start"]

# Run simple healthchecks every 5 mins, to check the Dashy's everythings great
HEALTHCHECK --interval=5m --timeout=2s --start-period=30s CMD yarn health-check
43 changes: 43 additions & 0 deletions Dockerfile-arm64v8
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM alpine:3.12 AS builder

# Download QEMU, see https://github.com/docker/hub-feedback/issues/1261
RUN QEMU_URL=https://github.com/balena-io/qemu/releases/download/v5.2.0%2Bbalena4/qemu-5.2.0.balena4-arm.tar.gz \
&& apk add curl && curl -L $QEMU_URL | tar zxvf - -C . --strip-components 1

# Start second (arm64v8) stage
FROM arm64v8/alpine:3.12

# Add QEMU from build stage
COPY --from=builder qemu-arm-static /usr/bin

# Install Node and Yarn
RUN apk add --update --no-cache nodejs npm yarn

# Define some ENV Vars
ENV PORT=80 \
DIRECTORY=/app \
IS_DOCKER=true

# Create and set the working directory
WORKDIR ${DIRECTORY}

# Copy over both 'package.json' and 'package-lock.json' (if available)
COPY package*.json ./

# Install project dependencies
RUN yarn

# Copy over all project files and folders to the working directory
COPY . .

# Build initial app for production
RUN yarn build

# Expose given port
EXPOSE ${PORT}

# Finally, run start command to serve up the built application
CMD [ "yarn", "build-and-start"]

# Run simple healthchecks every 5 mins, to check the Dashy's everythings great
HEALTHCHECK --interval=5m --timeout=2s --start-period=30s CMD yarn health-check
8 changes: 8 additions & 0 deletions hooks/pre-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# Source: https://github.com/ckulka/docker-multi-arch-example/blob/master/hooks/pre_build
# Used to setup QEMU to build arm images on amd64 processors.

# Register qemu-*-static for all supported processors except the
# current one, but also remove all registered binfmt_misc before
docker run --rm --privileged multiarch/qemu-user-static:register --reset