Skip to content

Commit 3bc872d

Browse files
committed
Clean Dockefile
- 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
1 parent ace0a83 commit 3bc872d

File tree

1 file changed

+31
-41
lines changed

1 file changed

+31
-41
lines changed

docker/Dockerfile

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,48 @@
1-
FROM alpine:latest
1+
FROM alpine:latest as build
22

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

5+
ARG PROJECT_NAME="armadietto"
6+
ARG PKG_MANAGER="yarn"
7+
ARG INSTALL_COMMAND="yarn install --pure-lockfile --production"
8+
9+
RUN mkdir /opt/armadietto
10+
WORKDIR /opt/armadietto
11+
12+
RUN apk add nodejs $PKG_MANAGER
13+
14+
COPY package.json ./
15+
COPY package-lock.json ./
16+
COPY yarn.lock ./
17+
18+
RUN $INSTALL_COMMAND
19+
20+
FROM alpine:latest
21+
522
ARG CONFIG_PATH_STORAGE="/usr/share/armadietto"
623
ARG PROJECT_NAME="armadietto"
724
ARG PORT="8000"
825
ARG USER="armadietto"
9-
ARG PKG_MANAGER="yarn"
10-
ARG INSTALL_COMMAND="yarn global --cache-folder /dev/shm/yarn-cache add"
1126

1227
ENV NODE_ENV production
1328
ENV PROJECT_NAME=$PROJECT_NAME
29+
ENV PORT=$PORT
1430

15-
RUN apk add nodejs $PKG_MANAGER
31+
RUN mkdir /opt/armadietto
32+
WORKDIR /opt/armadietto
33+
34+
RUN apk add nodejs
1635
RUN mkdir -m 0700 $CONFIG_PATH_STORAGE
1736
RUN adduser -u 6582 -HD $PROJECT_NAME
1837
RUN chown $PROJECT_NAME $CONFIG_PATH_STORAGE
1938

20-
RUN $INSTALL_COMMAND $PROJECT_NAME
39+
COPY --from=build /opt/armadietto/node_modules/ node_modules/
40+
COPY package.json ./
41+
COPY README.md ./
42+
COPY lib/ lib/
43+
COPY bin/ bin/
44+
45+
RUN ln -s /opt/armadietto/bin/armadietto.js /usr/local/bin/armadietto
2146

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

@@ -27,39 +52,4 @@ USER $PROJECT_NAME
2752

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

30-
HEALTHCHECK CMD curl --fail http://127.0.0.1:$PORT/ || exit 1
31-
32-
### Install ###
33-
#
34-
# BUILD:
35-
#
36-
# default for amd64 architecture
37-
#
38-
# > docker build -t armadietto:latest .
39-
# > docker build -t --build-arg PKG_MANAGER="npm" --build-arg INSTALL_COMMAND="npm i -g" armadietto:latest .
40-
#
41-
# RUN:
42-
#
43-
# > docker run --rm -p 8000:8000 rarmadietto:latest
44-
#
45-
# INFO: config.json needs to be byside the Dockerfile
46-
#
47-
# {
48-
# "allow_signup": true,
49-
# "storage_path": "/usr/share/armadietto",
50-
# "cache_views": true,
51-
# "http": {
52-
# "host": "0.0.0.0",
53-
# "port": 8000
54-
# },
55-
# "https": {
56-
# "enable": false,
57-
# "force": false,
58-
# "port": 4443,
59-
# "cert": "/etc/letsencrypt/live/example.com/cert.pem",
60-
# "key": "/etc/letsencrypt/live/example.com/privkey.pem"
61-
# },
62-
# "basePath": ""
63-
# }
64-
#
65-
###
55+
HEALTHCHECK --start-period=10s CMD wget -q -O /dev/null http://127.0.0.1:$PORT/

0 commit comments

Comments
 (0)