diff --git a/build/frappe-socketio/Dockerfile b/build/frappe-socketio/Dockerfile index f9d5f817..858a7f22 100644 --- a/build/frappe-socketio/Dockerfile +++ b/build/frappe-socketio/Dockerfile @@ -1,35 +1,23 @@ FROM alpine/git as builder -ARG GIT_REPO=https://github.com/frappe/frappe.git -ARG GIT_BRANCH=develop +ARG FRAPPE_VERSION +RUN git clone --depth 1 -b ${FRAPPE_VERSION} https://github.com/frappe/frappe /opt/frappe -RUN git clone --depth 1 -b ${GIT_BRANCH} ${GIT_REPO} /opt/frappe +FROM node:17-alpine -FROM node:bullseye-slim +RUN addgroup -S frappe \ + && adduser -S frappe -G frappe +USER frappe -# Add frappe user -RUN useradd -ms /bin/bash frappe WORKDIR /home/frappe/frappe-bench +RUN mkdir -p sites apps/frappe -# Create bench directories and set ownership -RUN mkdir -p sites apps/frappe \ - && chown -R frappe:frappe /home/frappe - -# Download socketio -COPY build/frappe-socketio/package.json apps/frappe -COPY --from=builder /opt/frappe/socketio.js apps/frappe/socketio.js -COPY --from=builder /opt/frappe/node_utils.js apps/frappe/node_utils.js +COPY --from=builder /opt/frappe/socketio.js /opt/frappe/node_utils.js apps/frappe/ +COPY package.json apps/frappe/ RUN cd apps/frappe \ - && npm install --only=prod + && npm install -# Setup docker-entrypoint -COPY build/frappe-socketio/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh -# backwards compat -RUN ln -s /usr/local/bin/docker-entrypoint.sh / - -USER frappe WORKDIR /home/frappe/frappe-bench/sites -ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["start"] +CMD [ "node", "/home/frappe/frappe-bench/apps/frappe/socketio.js" ] diff --git a/build/frappe-socketio/docker-entrypoint.sh b/build/frappe-socketio/docker-entrypoint.sh deleted file mode 100755 index ec347813..00000000 --- a/build/frappe-socketio/docker-entrypoint.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -set -e - -function checkConfigExists() { - COUNTER=0 - while [[ ! -e /home/frappe/frappe-bench/sites/common_site_config.json && ${COUNTER} -le 30 ]]; do - sleep 1 - ((COUNTER = COUNTER + 1)) - echo "config file not created, retry ${COUNTER}" >&2 - done - - if [[ ! -e /home/frappe/frappe-bench/sites/common_site_config.json ]]; then - echo "timeout: config file not created" >&2 - exit 1 - fi -} - -if [[ "$1" == 'start' ]]; then - checkConfigExists - node /home/frappe/frappe-bench/apps/frappe/socketio.js -else - exec -c "$@" -fi diff --git a/build/frappe-socketio/package.json b/build/frappe-socketio/package.json index 0c969142..04539034 100644 --- a/build/frappe-socketio/package.json +++ b/build/frappe-socketio/package.json @@ -2,10 +2,6 @@ "name": "frappe-socketio", "version": "1.0.1", "description": "Frappe SocketIO Server", - "main": "socketio.js", - "scripts": { - "start": "node socketio.js" - }, "author": "Revant Nandgaonkar", "license": "MIT", "dependencies": {