# Use a specific version of the node image as a base FROM node:16-alpine # Install necessary dependencies including JDK, Python, pip, and g++ RUN apk add --no-cache openjdk11 python3 py3-pip g++ # Set working directory WORKDIR /code # Copy package.json and package-lock.json and install dependencies COPY package*.json ./ RUN npm install --production # Copy the rest of the application files COPY . . # Create a directory for temporary files RUN mkdir -p /code/temp && \ chmod 777 /code/temp && \ touch /code/javac_output.txt && \ chmod 777 /code/javac_output.txt # Expose port EXPOSE 7860 # Set user to non-root USER node # Compile and run Java code CMD ["sh", "-c", "javac -d /code/temp /code/temp/*.java 2>&1 | tee /code/javac_output.txt && java -cp /code/temp Main"]