Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pawan jsp python #102

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
3 changes: 1 addition & 2 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
version: 0.0
os: linux

hooks:
ApplicationStop:
- location: scripts/stop_container.sh
Expand All @@ -9,4 +8,4 @@ hooks:
AfterInstall:
- location: scripts/start_container.sh
timeout: 300
runas: root
runas: root
13 changes: 13 additions & 0 deletions day-14/appspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 0.0
os: linux

hooks:
BeforeInstall:
- location: scripts/stop_container.sh
timeout: 300
runas: root

AfterInstall:
- location: scripts/start_container.sh
timeout: 300
runas: root
2 changes: 1 addition & 1 deletion day-14/simple-python-app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def hello():

if __name__ == '__main__':
app.run()

from
12 changes: 6 additions & 6 deletions day-14/simple-python-app/buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ version: 0.2

env:
parameter-store:
DOCKER_REGISTRY_USERNAME: /myapp/docker-credentials/username
DOCKER_REGISTRY_PASSWORD: /myapp/docker-credentials/password
DOCKER_REGISTRY_USERNAME: /myapp/docker-cerdentials/username
DOCKER_REGISTRY_PASSWORD: /myapp/docker-cerdentials/password
DOCKER_REGISTRY_URL: /myapp/docker-registry/url
phases:
install:
Expand All @@ -12,20 +12,20 @@ phases:
pre_build:
commands:
- echo "Installing dependencies..."
- pip install -r day-13/simple-python-app/requirements.txt
- pip install -r day-14/simple-python-app/requirements.txt
build:
commands:
- echo "Running tests..."
- cd day-13/simple-python-app/
- cd day-14/simple-python-app/
- echo "Building Docker image..."
- echo "$DOCKER_REGISTRY_PASSWORD" | docker login -u "$DOCKER_REGISTRY_USERNAME" --password-stdin "$DOCKER_REGISTRY_URL"
- docker build -t "$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/simple-python-flask-app:latest" .
- docker push "$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/simple-python-flask-app:latest"
- docker push "docker.io/$DOCKER_REGISTRY_USERNAME/simple-python-flask-app:latest"
post_build:
commands:
- echo "Build completed successfully!"
artifacts:
files:
- '**/*'
base-directory: ../simple-python-app
base-directory: day-14/simple-python-app

5 changes: 3 additions & 2 deletions day-14/simple-python-app/start_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
set -e

# Pull the Docker image from Docker Hub
echo
docker pull baggipawan/simple-python-flask-app

# Run the Docker image as a container
echo
docker run -d -p 5000:5000 baggipawan/simple-python-flask-app

3 changes: 2 additions & 1 deletion day-14/simple-python-app/stop_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
set -e

# Stop the running container (if any)
echo "Hi"
containerid='docker ps | awk -F " " '{print $1}'
docker rm -f $containerid
12 changes: 12 additions & 0 deletions python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 0.0
os: linux

hooks:
ApplicationStop:
- location: scripts/stop_container.sh
timeout: 300
runas: root
AfterInstall:
- location: scripts/start_container.sh
timeout: 300
runas: root
4 changes: 2 additions & 2 deletions scripts/start_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

# Pull the Docker image from Docker Hub
docker pull abhishekf5/simple-python-flask-app
docker pull baggipawan/simple-python-flask-app

# Run the Docker image as a container
docker run -d -p 5000:5000 abhishekf5/simple-python-flask-app
docker run -d -p 5000:5000 baggipawan/simple-python-flask-app
2 changes: 1 addition & 1 deletion scripts/stop_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
set -e

# Stop the running container (if any)
echo "Hi"
echo "Hi"