diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b2ef3b0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +# Use the official Nginx image as the base image +FROM nginx:latest + +# Copy custom Nginx configuration for client-side routing +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Clear the default Nginx web content folder +RUN rm -rf /usr/share/nginx/html/* + +# Install Git +RUN apt-get update && apt-get install -y git + +# Set the working directory to the Nginx web content folder +WORKDIR /usr/share/nginx/html + +# Clone the content of the specified GitHub repository +RUN git clone https://gitty.informatik.hs-mannheim.de/Maradona/FrontendDist . + +# Expose port 80 +EXPOSE 80 + +# Create a script to perform git pull on startup +RUN echo "#!/bin/sh" > /usr/share/nginx/html/update.sh && \ + echo "cd /usr/share/nginx/html && git pull" >> /usr/share/nginx/html/update.sh && \ + chmod +x /usr/share/nginx/html/update.sh + +# Start Nginx and run the update script +CMD /usr/share/nginx/html/update.sh && nginx -g 'daemon off;' \ No newline at end of file diff --git a/scripts/docker-build.py b/scripts/docker-build.py new file mode 100644 index 0000000..0ef20ba --- /dev/null +++ b/scripts/docker-build.py @@ -0,0 +1,22 @@ +import subprocess + +def build_docker_image(image_name, tag="latest"): + try: + subprocess.run(["docker", "build", "-t", f"{image_name}:{tag}", "."], check=True) + print(f"Successfully built Docker image: {image_name}:{tag}") + except subprocess.CalledProcessError as e: + print(f"Error building Docker image: {e}") + +def tag_and_push_image(image_name, tag="latest"): + try: + subprocess.run(["docker", "tag", f"{image_name}:{tag}", f"{image_name}:{tag}"], check=True) + subprocess.run(["docker", "push", f"{image_name}:{tag}"], check=True) + print(f"Successfully tagged and pushed Docker image: {image_name}:{tag}") + except subprocess.CalledProcessError as e: + print(f"Error tagging and pushing Docker image: {e}") + +if __name__ == "__main__": + docker_image_name = "teammaradona/frontend" + docker_image_tag = "latest" + build_docker_image(docker_image_name, docker_image_tag) + tag_and_push_image(docker_image_name, docker_image_tag)