Skip to content

Commit

Permalink
Improved workflow;
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnandagopal committed Jan 12, 2024
1 parent 35b7bca commit 239ae7c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 54 deletions.
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
pyproject.toml
poetry.lock
README.md
.github/
.gitignore
Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ jobs:
cd ./deploy/${{ github.event.repository.name }}
git pull
docker rm --force ${{ github.event.repository.name }}-deploy
cd ../
if test -f docker-compose.yml; then
docker compose build --quiet
docker compose up --detach
echo "Built and deployed container"
else
echo "Docker compose file not found"
docker build -t cyscomvit/${{ github.event.repository.name }}:latest --quiet .
docker run --detach --name ${{ github.event.repository.name }}-deploy cyscomvit/${{ github.event.repository.name }}:latest
fi
docker build -t ${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}:${{ github.event.sha }} --quiet .
docker run --detach --name ${{ github.event.repository.name }}-deploy ${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}:${{ github.event.sha }}
docker container prune --force && docker image prune --all --force
35 changes: 0 additions & 35 deletions .github/workflows/update-requirements-file.yml

This file was deleted.

26 changes: 19 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
FROM python:3.11.7-slim
FROM python:3.11.7-slim AS base-image

ENV PYTHONUNBUFFERED=1

RUN ["pip","install","poetry>=1.7,<1.8","--upgrade"]

RUN ["poetry","self","add","poetry-plugin-export"]

WORKDIR /export

COPY pyproject.toml poetry.lock ./

RUN ["poetry","export","--format","requirements.txt","--output","requirements.txt"]

FROM python:3.11.7-slim AS runtime-image

LABEL description="CYSCOM VIT's discord bot"

ENV PYTHONUNBUFFERED=1
COPY --from=base-image /export/requirements.txt requirements.txt

COPY requirements.txt requirements.txt
RUN ["useradd","--create-home","cyscom-docker"]

RUN ["pip","install","-r","requirements.txt"]
USER cyscom-docker

RUN useradd --create-home cyscom-docker
RUN ["pip","install","--requirement","requirements.txt"]

WORKDIR /home/cyscom-docker/discord-bot

WORKDIR /discord-bot

COPY . .

CMD python3 bot.py

0 comments on commit 239ae7c

Please sign in to comment.