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
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [gcc, clang]

steps:
- uses: actions/checkout@v4
- name: Install compiler
run: sudo apt-get update && sudo apt-get install -y ${{ matrix.compiler }}
- name: Build
run: make CC=${{ matrix.compiler }}
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and Push Multiarch Docker image to GHCR

on:
push:
branches:
- master

jobs:
build-and-push:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- 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 (multiarch)
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:latest
platforms: linux/amd64,linux/arm64
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM gcc:latest AS builder

WORKDIR /usr/src/app

COPY . .

RUN make

FROM debian:bookworm AS runtime

WORKDIR /usr/src/app

COPY --from=builder /usr/src/app/sort .
ENV TERM=xterm
CMD ["./sort"]
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

![Contributions](https://img.shields.io/static/v1.svg?label=Contributions&message=Welcome&color=information&style=for-the-badge)

![Docker](https://img.shields.io/badge/Docker-2496ED?style=for-the-badge&logo=docker&logoColor=white)
![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge&logo=ubuntu&logoColor=white)
![MAC](https://img.shields.io/badge/MAC-000000?style=for-the-badge&logo=macos&logoColor=white)
![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white)
Expand Down Expand Up @@ -44,7 +45,30 @@ Save results in a text file | NO
Display arrays | YES
Display execution time | YES

Note: you need to have the [GCC compiler](https://gcc.gnu.org/) installed in your machine to execute the instructions below to run the program.
Note: you need to have the [GCC compiler](https://gcc.gnu.org/) or docker environment installed in your machine to execute the instructions below to run the program.
___
#### Generated Image From Packages
- Pull the image:
```shell
docker pull ghcr.io/h-ssiqueira/sort_algorithms:latest
```
- Run the image into a container:
```shell
docker run -it --rm \
-v /data.txt:/usr/src/app/data.txt \
ghcr.io/h-ssiqueira/sort_algorithms:latest
```
#### Docker
- Build the image:
```shell
docker build -t sort_algorithms .
```
- Execute the image:
```shell
docker run -it --rm \
-v /data.txt:/usr/src/app/data.txt \
sort_algorithms
```
___
#### Linux & MAC
Open a terminal and go to project's directory. Execute ```make``` in terminal allow to compile the program. Commands avaliable to execute with make (```make ${command}```):
Expand Down