Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Monorepo by Reducing Artifact and Build Sizes through Package Cleanup and Dependency Updates #110

Merged
merged 11 commits into from
Nov 11, 2024
Merged
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,5 @@ build
/.idea/

/diagrams/
.DS_Store
.DS_Store
.run/
13 changes: 0 additions & 13 deletions .run/Apollon (Server + Webapp).run.xml

This file was deleted.

23 changes: 0 additions & 23 deletions .run/Apollon (Server).run.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .run/Apollon (Webapp).run.xml

This file was deleted.

32 changes: 21 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,58 @@
# multistage docker build
# Multistage Docker build

# should be a absolute path
# Define build directory as an absolute path
ARG build_dir=/build_application

# first stage which builds the application
FROM node:18
# First stage: Builds the application
FROM node:20.18.0 as builder

ARG build_dir
ENV DEPLOYMENT_URL="http://localhost:8080"

# make build dir
# Set up the build directory
WORKDIR $build_dir

# Copy all project files into the build directory
COPY . .

# Install dependencies and build the application
RUN npm install
RUN npm run build

# second stage which creates the container image to run the application
FROM node:18
# Second stage: Sets up the container to run the application
FROM node:20.18.0

# Install cron for scheduling
RUN apt-get update && apt-get -y install cron

# Expose the application's default port
EXPOSE 8080

# Create a user and set up necessary directories and permissions
RUN useradd -r -s /bin/false apollon_standalone \
&& mkdir /opt/apollon_standalone \
&& touch /var/log/cron.log \
&& chmod 622 /var/log/cron.log

# Start cron service
RUN service cron start
RUN chown -R apollon_standalone /opt/apollon_standalone

# Switch to non-root user for security
USER apollon_standalone
WORKDIR /opt/apollon_standalone

# Create a directory for storing diagrams
RUN mkdir diagrams

ARG build_dir

# copies build result from first stage
COPY --chown=apollon_standalone:apollon_standalone --from=0 $build_dir .
# Copy build results from the first stage
COPY --chown=apollon_standalone:apollon_standalone --from=builder $build_dir .

# Add cron job for deleting stale diagrams
RUN crontab delete-stale-diagrams.cronjob.txt

# Set the working directory for the server
WORKDIR /opt/apollon_standalone/build/server

# Start the application
CMD [ "node", "./src/main/server.js" ]
Loading