#!/bin/bash
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
dnf remove runc -y
dnf update -y
dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
dnf -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
systemctl --now enable docker
docker run hello-world
cat << EOF >> program.cpp
#include <iostream>
#include <fstream>
#include <string>

int main() {
    std::string filename = "/mnt/data/input.txt"; // Assuming the file is mounted at /data in the container

    while (true) {
        std::ifstream file(filename);
        if (file.is_open()) {
            std::string line;
            while (std::getline(file, line)) {
                std::cout << line << std::endl;
            }
            file.close();
        } else {
            std::cerr << "Unable to open file: " << filename << std::endl;
        }
    }

    return 0;
}
EOF
mkdir /mnt/data
echo "This file contains data." >> /mnt/data/input.txt
cat << EOF >> Dockerfile
FROM gcc:latest

COPY . ./app
WORKDIR /app

RUN g++ -std=c++11 -DSCCACHE_SALT=2 -fno-strict-aliasing -march=x86-64 -fPIC -ftls-model=initial-exec -fno-plt -g -O2 -fno-omit-frame-pointer -pthread -o program program.cpp
RUN chmod +x program
RUN mkdir -p /mnt/data

ENTRYPOINT ["./program"]
EOF
docker build -t program .
docker run -v /mnt/data/:/mnt/data program

Updated: