diff --git a/.github/workflows/docker-publish.yml b/.forgejo/workflows/docker-publish.yml similarity index 83% rename from .github/workflows/docker-publish.yml rename to .forgejo/workflows/docker-publish.yml index 565eda4..ba7fb87 100644 --- a/.github/workflows/docker-publish.yml +++ b/.forgejo/workflows/docker-publish.yml @@ -1,15 +1,18 @@ -name: Build and Publish Docker Image +name: Docker Build & Publish on: release: types: [created] + workflow_dispatch: + env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + CTR_REGISTRY: git.nickorlow.com + IMAGE_NAME: "anthracite" jobs: build: runs-on: ubuntu-latest + permissions: contents: read packages: write @@ -30,11 +33,11 @@ jobs: echo Building with version number $RELEASE_VERSION echo $RELEASE_VERSION > src/build/version.txt - - name: Log into registry ${{ env.REGISTRY }} + - name: Log into registry ${{ env.CTR_REGISTRY }} if: github.event_name != 'pull_request' uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c with: - registry: ${{ env.REGISTRY }} + registry: ${{ env.CTR_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} @@ -42,7 +45,7 @@ jobs: id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ env.CTR_REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker image id: build-and-push diff --git a/.gitignore b/.gitignore index a73eb30..2058835 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build/ build_supp/version.cpp +.cache/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 94046c8..273dfc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,23 +15,11 @@ add_custom_target(build-version add_custom_target(build-supplemental COMMAND cd ../build_supp && python3 ./error_gen.py - COMMAND cp -r ../www . - DEPENDS build_supp/version.txt www/* build_supp/error_gen.py build-version + COMMAND mkdir www && cp -r ../default_www/regular/* ./www/ + DEPENDS build_supp/version.txt ../default_www/regular/* build_supp/error_gen.py build-version COMMENT "Generated supplemental build files (default www dir + error pages)" ) -add_custom_target(lint - COMMAND clang-tidy *.cpp -) - -add_custom_target(lint-fix - COMMAND clang-tidy *.cpp -fix -fix-errors -) - -add_custom_target(build-docker - COMMAND docker build .. -t anthracite -) - add_custom_target(run COMMAND anthracite-bin DEPENDS anthracite-bin diff --git a/Dockerfile b/Dockerfile index dfc2581..c1f60f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,21 @@ FROM alpine as build-env RUN apk add --no-cache build-base python3 cmake -COPY ./src/ . -RUN rm -rf CMakeCache.txt CMakeFiles -RUN cmake -DCMAKE_BUILD_TYPE=Release . +COPY ./src ./src +COPY ./lib ./lib +COPY ./default_www ./default_www +COPY ./build_supp ./build_supp +COPY ./CMakeLists.txt . + + +RUN mkdir build +WORKDIR build +RUN cmake -DCMAKE_BUILD_TYPE=Release .. RUN make anthracite-bin FROM alpine -RUN apk add --no-cache build-base -COPY --from=build-env /anthracite /anthracite -COPY --from=build-env /www /www -COPY --from=build-env /error_pages /error_pages +RUN apk add --no-cache libgcc libstdc++ +COPY --from=build-env /build/anthracite-bin /anthracite-bin +COPY --from=build-env /build/error_pages /error_pages +COPY /default_www/docker /www CMD ["/anthracite-bin"] diff --git a/README.md b/README.md index b9606d3..0352b11 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Create a `build/` directory, run `cmake ..`, and then `make` to build. - [x] Multithreading - [x] HTTP/1.1 - [x] Enhance logging -- [-] Build out module-based backend system for handling requests +- [x] Create library that can be used to implement custom backends (i.e. webapi, fileserver, etc) - [ ] Faster parsing - [ ] HTTP/2 - [ ] Improve benchmarking infrastructure diff --git a/default_www/docker/favicon.ico b/default_www/docker/favicon.ico new file mode 100644 index 0000000..edcb3e4 Binary files /dev/null and b/default_www/docker/favicon.ico differ diff --git a/default_www/docker/index.html b/default_www/docker/index.html new file mode 100644 index 0000000..21e22a5 --- /dev/null +++ b/default_www/docker/index.html @@ -0,0 +1,9 @@ + + Anthracite + + +
+

Anthracite is Running in Docker!

+

If you are seeing this page, then Anthracite is configured correctly!

+

Add files to the "www" directory in your build step to begin serving your website.

+
diff --git a/default_www/docker_compose/favicon.ico b/default_www/docker_compose/favicon.ico new file mode 100644 index 0000000..edcb3e4 Binary files /dev/null and b/default_www/docker_compose/favicon.ico differ diff --git a/default_www/docker_compose/index.html b/default_www/docker_compose/index.html new file mode 100644 index 0000000..3607bbd --- /dev/null +++ b/default_www/docker_compose/index.html @@ -0,0 +1,9 @@ + + Anthracite + + +
+

Anthracite is Running in Docker Compose!

+

If you are seeing this page, then Anthracite is configured correctly!

+

Bind-mount a directory to "/www" to begin serving your website.

+
diff --git a/default_www/regular/favicon.ico b/default_www/regular/favicon.ico new file mode 100644 index 0000000..edcb3e4 Binary files /dev/null and b/default_www/regular/favicon.ico differ diff --git a/www/index.html b/default_www/regular/index.html similarity index 78% rename from www/index.html rename to default_www/regular/index.html index 558da13..5fe9382 100644 --- a/www/index.html +++ b/default_www/regular/index.html @@ -1,6 +1,6 @@ Anthracite - +

Anthracite is Running!

diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e89cc51 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + anthracite-web: + build: . + ports: + - "8080:80" + volumes: + - type: bind + source: ./default_www/docker_compose/ + target: /www diff --git a/lib/socket/socket.cpp b/lib/socket/socket.cpp index 055d7a7..720f668 100644 --- a/lib/socket/socket.cpp +++ b/lib/socket/socket.cpp @@ -11,6 +11,8 @@ namespace anthracite::socket { +const struct timeval anthracite_socket::timeout_tv = { .tv_sec = 5, .tv_usec = 0}; + anthracite_socket::anthracite_socket(int port, int max_queue) : server_socket(::socket(AF_INET, SOCK_STREAM, 0)) , client_ip("")