Skip to content

Commit

Permalink
more build stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Reynolds committed Apr 28, 2024
1 parent 3075eb0 commit a3a92ce
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
6 changes: 5 additions & 1 deletion labapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ WORKDIR /app
COPY app .
RUN pip install --no-cache-dir -r requirements.txt

CMD ["python", "./app.py"]
EXPOSE 5000
ENV FLASK_APP app.py
ENV FLASK_RUN_HOST 0.0.0.0

CMD ["flask", "run"]
49 changes: 49 additions & 0 deletions labapp/service_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# Update apt
sudo DEBIAN_FRONTEND=noninteractive apt-get update --yes

# Check if Docker is installed, install it if it's not
if ! command -v docker &> /dev/null
then
echo "Docker could not be found, installing..."
sudo apt-get install -y docker.io
fi

# Enable and start Docker
sudo systemctl enable docker
sudo systemctl start docker

# Variable Declarations
IMAGE=ghcr.io/f5devcentral/f5xc-lab-mcn-practical/labapp:latest
SERVICE=mcn-practical-labapp.service
CONTAINER=mcn-practical-labapp

# Create the systemd service file
sudo bash -c "cat > /etc/systemd/system/$SERVICE <<EOF
[Unit]
Description=Orijen UDF Service
Requires=docker.service
After=docker.service
[Service]
TimeoutStartSec=0
Restart=always
ExecStartPre=-/usr/bin/docker stop $IMAGE
ExecStartPre=-/usr/bin/docker rm $IMAGE
ExecStartPre=/usr/bin/docker pull $IMAGE
ExecStart=/usr/bin/docker run -p 1337:5000 --rm --name $CONTAINER $IMAGE
ExecStop=/usr/bin/docker stop $CONTAINER
[Install]
WantedBy=multi-user.target
EOF"

# Reload systemd manager configuration
sudo systemctl daemon-reload

# Enable and start your app service
sudo systemctl enable $SERVICE
sudo systemctl start $SERVICE

echo "$SERVICE has been installed and started as a systemd service."

0 comments on commit a3a92ce

Please sign in to comment.