diff --git a/Dockerfile b/Dockerfile index c1cf0d0..cf9ab67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,29 @@ -FROM node:16-alpine +# ---- Base ---- +FROM alpine:3 AS base # Create app directory WORKDIR /usr/src/app +# Copy project file +COPY package.json . + +# Install required apk-packages +RUN apk add --no-cache nodejs npm tcpdump + + +# ---- Dependencies ---- +FROM base AS dependencies + # Install app dependencies -COPY package*.json ./ -RUN npm install +RUN npm install --only=production -# remove development dependencies -RUN npm prune --production -# Install required apk-packages & delete cache -RUN apk update && apk add tcpdump && rm -rf /var/cache/apk/* +# ---- Release ---- +FROM base AS release +# copy from build image +COPY --from=dependencies /usr/src/app/ ./ # Bundle app source COPY ./src/ . -CMD ["npm", "run", "start"] \ No newline at end of file +CMD ["npm", "run", "start"] diff --git a/build/docker-multiarch.sh b/build/docker-multiarch.sh new file mode 100755 index 0000000..2bbc1be --- /dev/null +++ b/build/docker-multiarch.sh @@ -0,0 +1,9 @@ +TAG="ruakij/rfmon-to-influx" +PLATFORM="linux/amd64,linux/arm64/v8,linux/arm/v7" +EXTRA_ARGS="$@" + +docker buildx build \ +--platform $PLATFORM \ +--tag $TAG \ +$EXTRA_ARGS \ +. diff --git a/build/docker-ownarch.sh b/build/docker-ownarch.sh new file mode 100755 index 0000000..c0807a8 --- /dev/null +++ b/build/docker-ownarch.sh @@ -0,0 +1,7 @@ +TAG="ruakij/rfmon-to-influx" +EXTRA_ARGS="$@" + +docker build \ +--tag $TAG \ +$EXTRA_ARGS \ +.