Skip to content

Commit

Permalink
Modify Dockerfile with suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bytesnz committed May 29, 2021
1 parent 61c8f37 commit ace0a83
Showing 1 changed file with 56 additions and 18 deletions.
74 changes: 56 additions & 18 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,65 @@
FROM node:lts-alpine
FROM alpine:latest

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

RUN mkdir /opt/armadietto
RUN mkdir -m 0700 /usr/share/armadietto
RUN adduser -u 6582 -HD armadietto
RUN chown armadietto /usr/share/armadietto
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"

WORKDIR /opt/armadietto
ENV NODE_ENV production
ENV PROJECT_NAME=$PROJECT_NAME

COPY package.json ./
COPY package-lock.json ./
RUN apk add nodejs $PKG_MANAGER
RUN mkdir -m 0700 $CONFIG_PATH_STORAGE
RUN adduser -u 6582 -HD $PROJECT_NAME
RUN chown $PROJECT_NAME $CONFIG_PATH_STORAGE

RUN npm i --production
RUN $INSTALL_COMMAND $PROJECT_NAME

COPY README.md ./
COPY bin/ bin/
COPY lib/ lib/
COPY docker/config.json /etc/armadietto.conf.json
RUN ln -s /opt/armadietto/bin/armadietto.js /usr/local/bin/armadietto

VOLUME [ "/usr/share/armadietto" ]
EXPOSE 8000
USER armadietto
VOLUME $CONFIG_PATH_STORAGE
EXPOSE $PORT
USER $PROJECT_NAME

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

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

CMD [ "armadietto", "-c", "/etc/armadietto.conf.json" ]
### 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": ""
# }
#
###

0 comments on commit ace0a83

Please sign in to comment.