Step nexus artifactory
-
2 vCPUs and 4 GiB of memory
-
50 GB
## run in docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh
docker run -d -p 8081:8081 --name nexus sonatype/nexus3
#!/bin/bash
set -e
NEXUS_VERSION="3.90.1-01"
NEXUS_USER="nexus"
NEXUS_HOME="/opt/nexus"
NEXUS_DATA="/opt/sonatype-work"
NEXUS_TAR="nexus-${NEXUS_VERSION}-linux-x86_64.tar.gz"
DOWNLOAD_URL="https://cdn.download.sonatype.com/repository/downloads-prod-group/3/${NEXUS_TAR}"
echo "=== Nexus Installation ==="
# Install packages
apt update -y
apt install -y openjdk-25-jdk wget tar curl
# Create user
if ! id "$NEXUS_USER" >/dev/null 2>&1; then
echo "Creating nexus user..."
useradd -m -s /bin/bash "$NEXUS_USER"
else
echo "Nexus user already exists"
fi
# Download Nexus only if missing
cd /opt
if [ ! -f "$NEXUS_TAR" ]; then
echo "Downloading Nexus..."
wget "$DOWNLOAD_URL"
else
echo "Nexus archive already exists"
fi
# Extract only if installation missing
if [ ! -d "$NEXUS_HOME" ]; then
echo "Extracting Nexus..."
tar -xzf "$NEXUS_TAR"
mv "nexus-${NEXUS_VERSION}" "$NEXUS_HOME"
else
echo "Nexus installation already exists"
fi
# Create data directory
mkdir -p "$NEXUS_DATA"
# Permissions
chown -R "$NEXUS_USER:$NEXUS_USER" "$NEXUS_HOME"
chown -R "$NEXUS_USER:$NEXUS_USER" "$NEXUS_DATA"
# Configure Nexus user
echo "run_as_user=\"$NEXUS_USER\"" > "$NEXUS_HOME/bin/nexus.rc"
# Create service if missing
if [ ! -f /etc/systemd/system/nexus.service ]; then
cat >/etc/systemd/system/nexus.service <<EOF
[Unit]
Description=Nexus Repository Manager
After=network.target
[Service]
Type=forking
User=nexus
LimitNOFILE=65536
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
fi
# Start service
systemctl daemon-reload
systemctl enable nexus
systemctl restart nexus
echo "Waiting for Nexus..."
sleep 60
systemctl status nexus --no-pager
echo ""
echo "Nexus URL:"
echo "http://<server-ip>:8081"
echo ""
echo "Admin password:"
echo "cat /opt/sonatype-work/nexus3/admin.password"
# docker login
docker login mcd.jfrog.io
docker login nexus.demo.com
docker login 54.172.110.146:8081
enable http login in docker nexus
# /etc/docker/daemon.json
{
"insecure-registries" : ["my-registry.local:5000", "ipaddress:8081"]
}
docker login ipaddress:8081
docker pull alpine:latest
docker tag alpine:latest 54.172.110.146:8081/qt-dev-dcoker/base_image/alpine:latest
docker push 54.172.110.146:8081/qt-dev-dcoker/base_image/alpine:latest
