From e16fd5bb877c058a962d9cbd343f34620b8a559b Mon Sep 17 00:00:00 2001 From: "A. Halim" <92740851+aleng1@users.noreply.github.com> Date: Thu, 23 Jan 2025 08:20:40 +0800 Subject: [PATCH] feat: Add Docker configuration for Tetris game - Create Dockerfile with Nginx Alpine base image - Configure Nginx to serve static files on port 5000 - Add comprehensive documentation in Dockerfile - Create .dockerignore to exclude unnecessary files --- .dockerignore | 6 ++++++ Dockerfile | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4679b38 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +.gitignore +.dockerignore +Dockerfile +README.md +LICENSE \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5d9214a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# Use the official nginx alpine as the base image for a lightweight container +# Alpine-based images are smaller in size and more secure +FROM nginx:alpine + +# Set the working directory in the container +# This is where our application files will be placed +WORKDIR /usr/share/nginx/html + +# Copy all files from the current directory (.) to the working directory in the container (.) +# This includes HTML, CSS, JavaScript, and other static files +COPY . . + +# Create custom Nginx configuration to listen on port 5000 +RUN echo 'server { \ + listen 5000; \ + server_name localhost; \ + location / { \ + root /usr/share/nginx/html; \ + index index.html index.htm; \ + } \ +}' > /etc/nginx/conf.d/default.conf + +# Expose port 5000 for the Nginx web server +# This matches the port mapping in the docker run command (-p 5000:5000) +EXPOSE 5000 + +# Start the Nginx server in the foreground +# The 'daemon off' directive is required to run nginx in the foreground +# This is important for Docker containers as they should run in the foreground +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file