Skip to content

Commit

Permalink
Clean Dockefile
Browse files Browse the repository at this point in the history
- Fix healthcheck
- Switch back to using local files for creation instead of global install
- Use build container for installing node modules
- Remove docs from Dockerfile
  • Loading branch information
bytesnz committed Oct 22, 2021
1 parent ace0a83 commit 3bc872d
Showing 1 changed file with 31 additions and 41 deletions.
72 changes: 31 additions & 41 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,48 @@
FROM alpine:latest
FROM alpine:latest as build

LABEL description="Armadietto NodeJS web service (a RemoteStorageJS backend)"

ARG PROJECT_NAME="armadietto"
ARG PKG_MANAGER="yarn"
ARG INSTALL_COMMAND="yarn install --pure-lockfile --production"

RUN mkdir /opt/armadietto
WORKDIR /opt/armadietto

RUN apk add nodejs $PKG_MANAGER

COPY package.json ./
COPY package-lock.json ./
COPY yarn.lock ./

RUN $INSTALL_COMMAND

FROM alpine:latest

ARG CONFIG_PATH_STORAGE="/usr/share/armadietto"
ARG PROJECT_NAME="armadietto"
ARG PORT="8000"
ARG USER="armadietto"
ARG PKG_MANAGER="yarn"
ARG INSTALL_COMMAND="yarn global --cache-folder /dev/shm/yarn-cache add"

ENV NODE_ENV production
ENV PROJECT_NAME=$PROJECT_NAME
ENV PORT=$PORT

RUN apk add nodejs $PKG_MANAGER
RUN mkdir /opt/armadietto
WORKDIR /opt/armadietto

RUN apk add nodejs
RUN mkdir -m 0700 $CONFIG_PATH_STORAGE
RUN adduser -u 6582 -HD $PROJECT_NAME
RUN chown $PROJECT_NAME $CONFIG_PATH_STORAGE

RUN $INSTALL_COMMAND $PROJECT_NAME
COPY --from=build /opt/armadietto/node_modules/ node_modules/
COPY package.json ./
COPY README.md ./
COPY lib/ lib/
COPY bin/ bin/

RUN ln -s /opt/armadietto/bin/armadietto.js /usr/local/bin/armadietto

COPY docker/config.json /etc/armadietto.conf.json

Expand All @@ -27,39 +52,4 @@ USER $PROJECT_NAME

CMD $PROJECT_NAME -c /etc/armadietto.conf.json

HEALTHCHECK CMD curl --fail http://127.0.0.1:$PORT/ || exit 1

### Install ###
#
# BUILD:
#
# default for amd64 architecture
#
# > docker build -t armadietto:latest .
# > docker build -t --build-arg PKG_MANAGER="npm" --build-arg INSTALL_COMMAND="npm i -g" armadietto:latest .
#
# RUN:
#
# > docker run --rm -p 8000:8000 rarmadietto:latest
#
# INFO: config.json needs to be byside the Dockerfile
#
# {
# "allow_signup": true,
# "storage_path": "/usr/share/armadietto",
# "cache_views": true,
# "http": {
# "host": "0.0.0.0",
# "port": 8000
# },
# "https": {
# "enable": false,
# "force": false,
# "port": 4443,
# "cert": "/etc/letsencrypt/live/example.com/cert.pem",
# "key": "/etc/letsencrypt/live/example.com/privkey.pem"
# },
# "basePath": ""
# }
#
###
HEALTHCHECK --start-period=10s CMD wget -q -O /dev/null http://127.0.0.1:$PORT/

0 comments on commit 3bc872d

Please sign in to comment.