From 157e0a286fd9169a84cb7d17b18d03c9ee546a52 Mon Sep 17 00:00:00 2001 From: PythonGermany <97847597+PythonGermany@users.noreply.github.com> Date: Fri, 25 Oct 2024 21:37:49 +0200 Subject: [PATCH 1/5] Fix alpine build errors --- include/poll/AConnection.hpp | 1 + src/utils/utils.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/include/poll/AConnection.hpp b/include/poll/AConnection.hpp index a203d4e..002f02f 100644 --- a/include/poll/AConnection.hpp +++ b/include/poll/AConnection.hpp @@ -10,6 +10,7 @@ #include "Address.hpp" #include "CallbackPointer.hpp" +#include "timeval.hpp" // WEBSERV_CONFIG ----------- ACONNECTION VALUES ------------------- /** diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index c4a8546..620b483 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -1,6 +1,7 @@ #include "utils.hpp" #include +#include #include std::string trim(const std::string& str, std::string chars) { From 5a1ea6220bf01d15deb5fcac5f21d1fc84d11e11 Mon Sep 17 00:00:00 2001 From: PythonGermany <97847597+PythonGermany@users.noreply.github.com> Date: Fri, 25 Oct 2024 21:38:14 +0200 Subject: [PATCH 2/5] Remove nonexistent cmake rule from help info --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 71d0bb0..5ee8acf 100644 --- a/Makefile +++ b/Makefile @@ -120,7 +120,6 @@ help: @echo " clean : Remove object files" @echo " fclean : Remove object files and the webserv binary" @echo " re : Rebuild the webserv binary (fclean + all)" - @echo " cgi : Build the CGI program" @echo " performance : Build with optimization flags (-O3)" @echo " debug : Build with debugging symbols (-g)" @echo " custom : Build with custom CXXFLAGS (e.g., ARG='-DDEBUG')" From 6b9152414d391922c1d0729d0a142cd027c76851 Mon Sep 17 00:00:00 2001 From: PythonGermany <97847597+PythonGermany@users.noreply.github.com> Date: Fri, 25 Oct 2024 22:29:02 +0200 Subject: [PATCH 3/5] Add dockerfile for standalone image --- Dockerfile | 25 +++++++++++++++++++++++ conf/sites-available/default.conf | 7 +++++++ websites/default/index.html | 33 +++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 Dockerfile create mode 100644 conf/sites-available/default.conf create mode 100644 websites/default/index.html diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..437c70c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM alpine:latest AS build-stage + +RUN apk add --no-cache make g++ + +COPY . /app + +RUN make -C /app fclean custom ARG="-static -O3" + +#FROM alpine:latest AS production-stage +FROM alpine:latest AS production-stage + +COPY --from=build-stage /app/bin/webserv /usr/bin/webserv +COPY --from=build-stage /app/conf/webserv.conf /etc/webserv/ +COPY --from=build-stage /app/conf/mime.types /etc/webserv/ +COPY --from=build-stage /app/conf/sites-available/default.conf /etc/webserv/sites-available/ + +RUN mkdir /etc/webserv/sites-enabled +RUN ln -s /etc/webserv/sites-available/default.conf /etc/webserv/sites-enabled/ + +RUN mkdir -p /var/www/html +COPY --from=build-stage /app/websites/default/index.html /var/www/html/ + +EXPOSE 8080 + +CMD ["/usr/bin/webserv"] diff --git a/conf/sites-available/default.conf b/conf/sites-available/default.conf new file mode 100644 index 0000000..3b371d2 --- /dev/null +++ b/conf/sites-available/default.conf @@ -0,0 +1,7 @@ +server { + listen 0.0.0.0:8080; + + root /var/www/html; + + index index.html index.htm; +} diff --git a/websites/default/index.html b/websites/default/index.html new file mode 100644 index 0000000..e51dd18 --- /dev/null +++ b/websites/default/index.html @@ -0,0 +1,33 @@ + + + + + Welcome to webserv! + + + + +

Welcome to webserv!

+

If you see this page, the webserv web server is successfully installed and + working. Further configuration is required.

+ +

For online documentation and support please refer to + github.com.
+ Commercial support is not available at + github.com. +

+ +

Thank you for using webserv.

+ + + From 579c08f619bdc81558dd745f410f9cfde4792bf4 Mon Sep 17 00:00:00 2001 From: PythonGermany <97847597+PythonGermany@users.noreply.github.com> Date: Fri, 25 Oct 2024 22:29:16 +0200 Subject: [PATCH 4/5] Add .dockerignore --- .dockerignore | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4b9f223 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,18 @@ +.clang-format +.clangd + +.git/ +.github/ + +.gitignore +.gitmodules + +.vscode/ +bin/ +cgi/ +docker/ +logs/ +obj/ +tests/ + +Dokerfile From b4982cdd978f8f4203633a36f14d144175f4edbb Mon Sep 17 00:00:00 2001 From: PythonGermany <97847597+PythonGermany@users.noreply.github.com> Date: Fri, 25 Oct 2024 22:29:41 +0200 Subject: [PATCH 5/5] Add docker standalone makefile rules --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 5ee8acf..d35fa3d 100644 --- a/Makefile +++ b/Makefile @@ -111,6 +111,12 @@ custom: run: all $(BIN_DIR)/$(NAME) $(CONF_DIR)/$(CONF) +docker.build: + docker build -t webserv . + +docker.run: + docker run --rm -p 8080:8080 --name webserv webserv:latest + lines: @wc -l $(SRC_DIR)/*.cpp $(INC_DIR)/*.hpp $(SRC_DIR)/*/*.cpp $(INC_DIR)/*/*.hpp | sort @@ -124,6 +130,8 @@ help: @echo " debug : Build with debugging symbols (-g)" @echo " custom : Build with custom CXXFLAGS (e.g., ARG='-DDEBUG')" @echo " run : Run webserv binary with project configuration file" + @echo " docker.build : Build webserv docker image" + @echo " docker.run : Run webserv docker image" @echo " lines : Count lines of code in source files" .PHONY: all clean fclean re performance debug fsanitize custom flamegraph jmeter lines help