Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.clang-format
.clangd

.git/
.github/

.gitignore
.gitmodules

.vscode/
bin/
cgi/
docker/
logs/
obj/
tests/

Dokerfile
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
7 changes: 7 additions & 0 deletions conf/sites-available/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
server {
listen 0.0.0.0:8080;

root /var/www/html;

index index.html index.htm;
}
1 change: 1 addition & 0 deletions include/poll/AConnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "Address.hpp"
#include "CallbackPointer.hpp"
#include "timeval.hpp"

// WEBSERV_CONFIG ----------- ACONNECTION VALUES -------------------
/**
Expand Down
1 change: 1 addition & 0 deletions src/utils/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "utils.hpp"

#include <algorithm>
#include <climits>
#include <list>

std::string trim(const std::string& str, std::string chars) {
Expand Down
33 changes: 33 additions & 0 deletions websites/default/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>

<head>
<title>Welcome to webserv!</title>
<style>
html {
color-scheme: light dark;
}

body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>

<body>
<h1>Welcome to webserv!</h1>
<p>If you see this page, the webserv web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="https://github.com/PythonGermany/42_webserv?tab=readme-ov-file#introduction">github.com</a>.<br />
Commercial support is not available at
<a href="https://github.com/PythonGermany/42_webserv">github.com</a>.
</p>

<p><em>Thank you for using webserv.</em></p>
</body>

</html>