Spaces:
Sleeping
Sleeping
| # Use the specific base image | |
| FROM python:3.8-slim-buster | |
| # Set up a new user named "user" with user ID 1000 | |
| RUN useradd -m -u 1000 user | |
| # Set up environment variables for the user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Set the working directory to the user's home directory | |
| WORKDIR $HOME/app | |
| # Install Java | |
| RUN apt-get update && apt-get install -y openjdk-11-jdk | |
| # Set the JAVA_HOME environment variable | |
| ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64 | |
| # Change ownership of the working directory to the user | |
| RUN chown -R user:user $HOME/app | |
| # Switch to the user | |
| USER user | |
| # Copy the Python files and Java program to the Docker image | |
| COPY app.py YourJavaProgram.java requirements.txt $HOME/app/ | |
| # Install required Python dependencies | |
| RUN pip install -r $HOME/app/requirements.txt | |
| # Compile the Java program | |
| RUN javac $HOME/app/YourJavaProgram.java | |
| # Expose the desired port | |
| EXPOSE 7860 | |
| # Set the command to run the Python application | |
| CMD ["python", "app.py"] |