diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e0881e3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +build/ +.git/ +.vscode/ \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ff87899 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,47 @@ +name: CI and Docker + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + packages: write + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Build Tools + run: | + sudo apt-get update + sudo apt-get install -y cmake gcc make + + - name: Configure CMake + run: cmake -B build + + - name: Build Project + run: cmake --build build + + - name: Run Unit Tests + run: ./build/unit_tests + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and Push Docker Image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ghcr.io/blazejoz/mini_shell:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f1d6ecf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM ubuntu:24.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + cmake \ + gcc \ + g++ \ + make \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +COPY . . + +RUN cmake -B build && cmake --build build + +ENTRYPOINT ["./build/mini_shell"] \ No newline at end of file