Skip to content

Instantly share code, notes, and snippets.

@thanoojgithub
Last active December 26, 2024 00:28
Show Gist options
  • Save thanoojgithub/2555e499201a9b8461686f38e374a7b3 to your computer and use it in GitHub Desktop.
Save thanoojgithub/2555e499201a9b8461686f38e374a7b3 to your computer and use it in GitHub Desktop.
Dockerfile - Ubuntu with basic Java configurations
# Use Ubuntu as base image
FROM ubuntu:25.04
# Set non-interactive frontend for apt
ENV DEBIAN_FRONTEND=noninteractive
# Install prerequisites
RUN apt update && apt upgrade -y && apt install -y \
wget \
curl \
git \
build-essential \
software-properties-common \
unzip \
vim \
neovim \
openjdk-21-jdk
# Install Gradle 8.11.1
RUN wget https://services.gradle.org/distributions/gradle-8.11.1-bin.zip -P /tmp && \
unzip /tmp/gradle-8.11.1-bin.zip -d /opt/ && \
ln -s /opt/gradle-8.11.1/bin/gradle /usr/bin/gradle
# Verify installations
RUN java -version && \
gradle -v && \
git -v && \
curl --version && \
wget --version && \
nvim --version
# Default work directory
WORKDIR /workspace
# Set container's entry point
CMD ["/bin/bash"]
@thanoojgithub
Copy link
Author

# Base Image
FROM ubuntu:22.04

# Set non-interactive frontend for apt
ENV DEBIAN_FRONTEND=noninteractive

# Update package list and install dependencies
RUN apt-get update && apt-get install -y \
    software-properties-common \
    wget \
    gnupg2 \
    lsb-release \
    && add-apt-repository ppa:openjdk-r/ppa \
    && apt-get update

# Install OpenJDK 21
RUN apt-get install -y openjdk-21-jdk

# Install PostgreSQL
RUN apt-get install -y postgresql postgresql-contrib

# Configure PostgreSQL to listen on all interfaces
RUN sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" /etc/postgresql/*/main/postgresql.conf

# Allow all IPs for PostgreSQL connections (adjust for security in production)
RUN echo "host all  all    0.0.0.0/0  trust" >> /etc/postgresql/*/main/pg_hba.conf

# Expose PostgreSQL default port
EXPOSE 5432

# Environment Variables for PostgreSQL
ENV POSTGRES_USER=postgres
ENV POSTGRES_PASSWORD=postgres

# Start PostgreSQL service
CMD service postgresql start && tail -f /dev/null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment