mirror of
https://github.com/aljazceru/gitpear.git
synced 2025-12-17 06:04:25 +01:00
docker and http
This commit is contained in:
35
Dockerfile
Normal file
35
Dockerfile
Normal file
@@ -0,0 +1,35 @@
|
||||
# Use the official Node.js image as the base image
|
||||
FROM node:latest
|
||||
|
||||
# install nginx
|
||||
RUN apt-get update && apt-get install -y nginx git fcgiwrap spawn-fcgi
|
||||
ENV GIT_PEAR=/srv/repos/pear
|
||||
EXPOSE 80
|
||||
STOPSIGNAL SIGTERM
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /app
|
||||
|
||||
# Clone the gitpear repository from GitHub
|
||||
RUN git clone https://github.com/dzdidi/gitpear.git
|
||||
|
||||
# Change the working directory to the gitpear directory
|
||||
WORKDIR /app/gitpear
|
||||
|
||||
# Install the dependencies using npm
|
||||
RUN npm install
|
||||
|
||||
# Link the gitpear package globally
|
||||
RUN npm link
|
||||
|
||||
RUN mkdir -p /srv/repos/pear
|
||||
|
||||
|
||||
COPY default /etc/nginx/sites-enabled/default
|
||||
|
||||
WORKDIR /app
|
||||
COPY entrypoint.sh .
|
||||
RUN chmod +x entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/bin/bash", "-c", "/app/entrypoint.sh"]
|
||||
|
||||
|
||||
18
default
Normal file
18
default
Normal file
@@ -0,0 +1,18 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
# This is where the repositories live on the server
|
||||
root /srv/repos/pear;
|
||||
|
||||
|
||||
location ~ (/.*) {
|
||||
fastcgi_pass unix:/var/run/fcgiwrap.socket;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
|
||||
# export all repositories under GIT_PROJECT_ROOT
|
||||
fastcgi_param GIT_HTTP_EXPORT_ALL "";
|
||||
fastcgi_param GIT_PROJECT_ROOT /srv/repos/pear;
|
||||
fastcgi_param PATH_INFO $1;
|
||||
}
|
||||
}
|
||||
46
entrypoint.sh
Normal file
46
entrypoint.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# if $1 includes an url
|
||||
exec > >(tee -a "/tmp/deployment.log") 2>&1
|
||||
|
||||
export GIT_PEAR=/srv/repos/pear
|
||||
git pear daemon -s
|
||||
# if $1 exists
|
||||
if [ -n "$1" ]; then
|
||||
REPO_NAME=$1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [[ $REPO_NAME =~ ^https.* ]]; then
|
||||
ORIGINAL_NAME=$(basename $REPO_NAME .git)
|
||||
mkdir -p /srv/repos/"$ORIGINAL_NAME"
|
||||
git clone $REPO_NAME /srv/repos/"$ORIGINAL_NAME"
|
||||
cd /srv/repos/"$ORIGINAL_NAME"
|
||||
git pear init -s
|
||||
# enter pear repo and expose http
|
||||
cd /srv/repos/pear/"$ORIGINAL_NAME"/
|
||||
echo "[http]" >> config
|
||||
echo " receivepack = true" >> config
|
||||
fi
|
||||
|
||||
|
||||
if [[ ! $REPO_NAME =~ ^https.* ]]; then
|
||||
mkdir -p /srv/repos/"$REPO_NAME"
|
||||
cd /srv/repos/"$REPO_NAME"
|
||||
git init
|
||||
git pear init -s
|
||||
# enter pear repo and expose http
|
||||
cd /srv/repos/pear/"$REPO_NAME"/
|
||||
echo "[http]" >> config
|
||||
echo " receivepack = true" >> config
|
||||
# git config --bool core.bare true
|
||||
fi
|
||||
echo "REPO_NAME: $REPO_NAME" >> /tmp/debug.log
|
||||
echo "ORIGINAL_NAME: $ORIGINAL_NAME" >> /tmp/debug.log
|
||||
echo "GIT_PEAR: $GIT_PEAR" >> /tmp/debug.log
|
||||
echo "PEAR_KEY: $PEAR_KEY" >> /tmp/debug.log
|
||||
echo "PEAR_REPO: $PEAR_REPO" >> /tmp/debug.log
|
||||
|
||||
/etc/init.d/fcgiwrap start
|
||||
chmod 766 /var/run/fcgiwrap.socket
|
||||
nginx -g "daemon off;"
|
||||
Reference in New Issue
Block a user