From 827194071201b1d722a429fed7d71eadc4aab417 Mon Sep 17 00:00:00 2001 From: Alexey-Sagaydak Date: Fri, 20 Sep 2024 01:30:18 +0700 Subject: [PATCH] add building docker image --- .github/workflows/ci.yaml | 18 +++++++++++++----- Dockerfile | 9 +++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index faabe3e..7ed4ae9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,7 +3,6 @@ run-name: ${{ github.actor }} run CI on: [push] jobs: - build-test: runs-on: ubuntu-latest @@ -44,11 +43,8 @@ jobs: - name: Test 4. Test server run: | libhv-http & SERVER_PID=$! - sleep 5 - curl --silent --head http://localhost:7777 | grep "HTTP/1.1 200 OK" > /dev/null - if [ "$?" -eq 0 ]; then echo "Сервер успешно запущен" kill $SERVER_PID @@ -57,4 +53,16 @@ jobs: echo "Ошибка при запуске сервера" kill $SERVER_PID exit 1 - fi \ No newline at end of file + fi + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build Docker image + run: docker build -t ${{ secrets.DOCKER_USERNAME }}/http-server:${{ github.sha }} . + + - name: Push Docker image + run: docker push ${{ secrets.DOCKER_USERNAME }}/http-server:${{ github.sha }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a10a440 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM ubuntu:22.04 + +RUN apt-get update && apt-get install -y libboost-all-dev + +COPY ./server/build/http-server /usr/local/bin/http-server + +EXPOSE 7777 + +CMD ["http-server"]