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 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/Makefile b/Makefile index 71d0bb0..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 @@ -120,11 +126,12 @@ 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')" @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 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/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) { 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.

+ + +