chore: Use single COPY command in Dockerfile for constant/static files (#27127)

Move the files that are copied into the Docker image, into an `fs`
folder, that reflects the folder structure of that in the image. This
means two things right away:

1. A single `COPY` instruction in `Dockerfile` is enough to copy all the
files to their places.
2. The structure of files in the repo reflects that in the Docker image.
This makes working with the files/folders and troubleshooting with them
much easier.

 Note: **There's actually only 3 files changed, rest are just moved.**
This commit is contained in:
Shrikant Sharat Kandula 2023-09-11 08:43:09 +05:30 committed by GitHub
parent 5a9e36604f
commit c594699eac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 13 additions and 40 deletions

View File

@ -14,12 +14,12 @@ on:
pull_request:
branches: [release, master]
paths:
- "deploy/docker/utils/**"
- "deploy/docker/fs/opt/appsmith/utils/**"
# Change the working directory for all the jobs in this workflow
defaults:
run:
working-directory: deploy/docker/utils/
working-directory: deploy/docker/fs/opt/appsmith/utils/
jobs:
build:

View File

@ -34,8 +34,7 @@ RUN curl --silent --show-error --location https://www.mongodb.org/static/pgp/ser
&& curl --silent --show-error --location https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& apt update \
&& apt-get install --no-install-recommends --yes mongodb-org nodejs redis build-essential postgresql-13 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
&& apt-get clean
# Clean up cache file - Service layer
RUN rm -rf \
@ -62,7 +61,9 @@ ENV APPSMITH_CLOUD_SERVICES_BASE_URL=${APPSMITH_CLOUD_SERVICES_BASE_URL}
ARG APPSMITH_SEGMENT_CE_KEY
ENV APPSMITH_SEGMENT_CE_KEY=${APPSMITH_SEGMENT_CE_KEY}
#Create the plugins directory
RUN mkdir -p ./backend ./editor ./rts ./backend/plugins ./templates ./utils
RUN mkdir -p ./editor ./rts ./backend/plugins
COPY deploy/docker/fs /
#Add the jar to the container
COPY ${JAR_FILE} backend/server.jar
@ -74,43 +75,16 @@ COPY ./app/client/build editor/
# Add RTS - Application Layer
COPY ./app/client/packages/rts/package.json ./app/client/packages/rts/dist rts/
# Nginx, MongoDB and PostgreSQL data config template - Configuration layer
COPY ./deploy/docker/templates/nginx/* \
./deploy/docker/templates/docker.env.sh \
./deploy/docker/templates/mockdb_postgres.sql \
./deploy/docker/templates/users_postgres.sql \
./deploy/docker/templates/appsmith_starting.html \
./deploy/docker/templates/appsmith_initializing.html \
templates/
# Add bootstrapfile
COPY ./deploy/docker/entrypoint.sh ./deploy/docker/scripts/* info.*json ./
# Add util tools
COPY ./deploy/docker/utils ./utils
RUN cd ./utils && npm install --only=prod && npm install --only=prod -g .
# Add process config to be run by supervisord
COPY ./deploy/docker/templates/supervisord.conf /etc/supervisor/supervisord.conf
COPY ./deploy/docker/templates/supervisord/ templates/supervisord/
# Add defined cron job
COPY ./deploy/docker/templates/cron.d /etc/cron.d/
RUN chmod 0644 /etc/cron.d/*
RUN chmod +x entrypoint.sh renew-certificate.sh healthcheck.sh
# Disable setuid/setgid bits for the files inside container.
RUN find / \( -path /proc -prune \) -o \( \( -perm -2000 -o -perm -4000 \) -print -exec chmod -s '{}' + \) || true
RUN cd ./utils && npm install --only=prod && npm install --only=prod -g . && cd - \
&& chmod 0644 /etc/cron.d/* \
&& chmod +x entrypoint.sh renew-certificate.sh healthcheck.sh /watchtower-hooks/*.sh \
# Disable setuid/setgid bits for the files inside container.
&& find / \( -path /proc -prune \) -o \( \( -perm -2000 -o -perm -4000 \) -print -exec chmod -s '{}' + \) || true
# Update path to load appsmith utils tool as default
ENV PATH /opt/appsmith/utils/node_modules/.bin:$PATH
LABEL com.centurylinklabs.watchtower.lifecycle.pre-check=/watchtower-hooks/pre-check.sh
LABEL com.centurylinklabs.watchtower.lifecycle.pre-update=/watchtower-hooks/pre-update.sh
COPY ./deploy/docker/watchtower-hooks /watchtower-hooks
RUN chmod +x /watchtower-hooks/pre-check.sh
RUN chmod +x /watchtower-hooks/pre-update.sh
EXPOSE 80
EXPOSE 443

View File

@ -1 +0,0 @@
node_modules/

View File

@ -39,4 +39,4 @@ jq -n \
--arg githubRunUrl "${github_run_url-}" \
--arg imageBuiltAt "$(date -u -Iseconds)" \
--argjson isCI "${CI:-false}" \
'$ARGS.named' | tee "$(git rev-parse --show-toplevel)/info.json"
'$ARGS.named' | tee "$(git rev-parse --show-toplevel)/deploy/docker/fs/opt/appsmith/info.json"