A Dockerfile, a text file used to build a Docker image, contains commands and instructions that enable the following operations:
Since ohpm-repo 5.4.3 Beta, you can use Docker commands to set up an ohpm-repo instance. This document describes how to implement this on Linux.
Environment setup
# Use the official Node.js 18 image.
FROM node:18
COPY ./ohpm-repo.zip /tmp/ohpm-repo.zip
RUN mkdir -p /opt/ohpm-repo && \
unzip /tmp/ohpm-repo.zip -d /opt/ohpm-repo && \
rm -f /tmp/ohpm-repo.zip
# Modify the listen configuration in conf/config.yaml. Do not use localhost or 127.0.0.1; instead, use 0.0.0.0.
RUN if [ -f /opt/ohpm-repo/conf/config.yaml ]; then \
sed -i 's/listen: [^ ]*/listen: 0.0.0.0:8088/g' /opt/ohpm-repo/conf/config.yaml; \
fi
ENV OHPM_REPO_BIN_DIR="/opt/ohpm-repo/bin"
ENV PATH="${OHPM_REPO_BIN_DIR}:${PATH}"
# Create a user. Do not run the ohpm-repo install and ohpm-repo start commands as the root user.
RUN useradd -m myuser && \
chown -R myuser:myuser /opt/ohpm-repo && \
chmod -R 755 /opt/ohpm-repo
USER myuser
RUN ohpm-repo install
ENV OHPM_REPO_DEPLOY_ROOT="/home/myuser/ohpm-repo"
CMD ["ohpm-repo", "start"] ohpm-repo service deployment
docker build -t ohpm-repo .
# Command to run it in the foreground docker run -it -p 8088:8088 ohpm-repo # Command to run it in the background docker run -d --restart=unless-stopped --name ohpm-repo -p 8088:8088 ohpm-repo