-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c219ea8
commit 0f30ac6
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Build and Publish Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build-and-publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 # Check out your repository's code | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Generate build date | ||
id: build_date | ||
run: echo "::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')" | ||
|
||
- name: Build the Docker image | ||
run: | | ||
docker build \ | ||
--file Dockerfile \ | ||
--tag ghcr.io/${{ github.repository_owner }}/hammy-mchamiton:${{ github.run_number }} \ | ||
--tag ghcr.io/${{ github.repository_owner }}/hammy-mchamilton:latest \ | ||
--build-arg BUILD_DATE=${{ steps.build_date.outputs.BUILD_DATE }} \ | ||
. | ||
env: | ||
BUILD_DATE: ${{ steps.build_date.outputs.BUILD_DATE }} | ||
|
||
- name: Push the Docker image to GitHub Container Registry | ||
run: | | ||
docker push ghcr.io/${{ github.repository_owner }}/hammy-mchamilton:${{ github.run_number }} | ||
docker push ghcr.io/${{ github.repository_owner }}/hammy-mchamilton:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Use official Python runtime as a parent image | ||
FROM python:3.9-slim | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the current directory contents into the container at /app | ||
COPY . /app | ||
|
||
# Install any needed dependencies specified in requirements.txt | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Define environment variable | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
# Add standard labels | ||
LABEL maintainer="Joshua Clarke and Antony Bailey <antony.bailey@thepoliceoftheinter.net>" | ||
LABEL description="This is a Docker image for the Hammy McHamilton Discord Bot." | ||
LABEL org.opencontainers.image.created="$BUILD_DATE" | ||
# docker build --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -t hammy-mchamilton . | ||
|
||
# Run main.py when the container launches | ||
CMD ["python", "main.py"] |