Skip to content
Open
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
18 changes: 18 additions & 0 deletions .github/workflows/github-actions-demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
38 changes: 38 additions & 0 deletions .github/workflows/github-actions-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
build:
runs-on: ubuntu-latest
needs: Explore-GitHub-Actions
steps:
- run: echo "Code Build"
lint:
runs-on: ubuntu-latest
needs: Explore-GitHub-Actions
steps:
- run: echo "Code Lint"
unittest:
runs-on: ubuntu-latest
needs: Explore-GitHub-Actions
steps:
- run: echo "Code Unittest"
deploy:
runs-on: ubuntu-latest
needs: [lint, unittest]
steps:
- run: echo "Code Deploy"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ dmypy.json
# Cython debug symbols
cython_debug/

vars/credentials.yaml

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
Expand Down
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#Ubuntu 22.04 base image
FROM ubuntu:22.04

#Copy the requirements file
COPY requirements.txt .

#Install python3
RUN apt-get update && apt-get install -y python3 python3-pip \
&& useradd -m -s /bin/bash nruser \
&& pip install -r requirements.txt \
&& mkdir /app

#Copy app
COPY --chown=nruser app /app

#Switch to the non-root user
USER nruser

#Add work dir
WORKDIR /app

#Add entrypoint
ENTRYPOINT [ "python3"]

#Run the app
CMD ["app.py"]
38 changes: 38 additions & 0 deletions docker-playbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
- hosts: localhost
gather_facts: no
vars:
image_name: fannymalinova/python_app_from_ansible
image_tag: v1.0.1
listen_port: 5000
vars_files:
- vars/credentials.yaml
tasks:
- name: Docker login
docker_login:
username: "{{ dockerhub_credentials['username'] }}"
password: "{{ dockerhub_credentials['password'] }}"
- name: Build an image from Dockerfile
docker_image:
build:
path: ./
name: "{{ image_name }}"
tag: "{{ image_tag }}"
push: yes
source: build
- name: Logout from Docker Hub
docker_login:
username: "{{ dockerhub_credentials['username'] }}"
state: absent
- name: Run a container from this image
docker_container:
name: python_app_from_ansible_container
image: "{{ image_name }}:{{ image_tag }}"
ports:
- "8080:{{ listen_port }}"
env:
PORT: "{{ listen_port | string }}"