Compare commits
12 Commits
CICD
...
263bea92f4
| Author | SHA1 | Date | |
|---|---|---|---|
| 263bea92f4 | |||
| 2e9641bf27 | |||
| 43e58a3717 | |||
| c3593d2109 | |||
| c04f3fa5f8 | |||
| 59c94e6c51 | |||
| 02f69f2e68 | |||
| cd112fa644 | |||
| dba4cf01a3 | |||
| 01cf5d641b | |||
| 1a673f866f | |||
|
|
8d99fc5595 |
13
.env
Normal file
13
.env
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Environment Variables used to configure WMGZON
|
||||||
|
|
||||||
|
# ENVIRON: Used to incidicate the type of environment the app is running in.
|
||||||
|
# DEFAULT = prod
|
||||||
|
|
||||||
|
ENVIRON=prod
|
||||||
|
# ENVIRON=test
|
||||||
|
|
||||||
|
# App secret used to encrpy client-side cookies
|
||||||
|
APPSECRET=test
|
||||||
|
|
||||||
|
# Filestore for product photos
|
||||||
|
FILESTORE=static/assets/img/products/
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -17,7 +17,6 @@ cicd/runner-data
|
|||||||
instance/*
|
instance/*
|
||||||
!instance/.gitignore
|
!instance/.gitignore
|
||||||
.webassets-cache
|
.webassets-cache
|
||||||
.env
|
|
||||||
|
|
||||||
### Flask.Python Stack ###
|
### Flask.Python Stack ###
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
variables:
|
variables:
|
||||||
APPSECRET: "test"
|
|
||||||
ENVIRON: "test"
|
|
||||||
FILESTORE: "static/assets/img/products/"
|
|
||||||
DOCKER_HOST: tcp://docker:2375/
|
DOCKER_HOST: tcp://docker:2375/
|
||||||
DOCKER_DRIVER: overlay2
|
DOCKER_DRIVER: overlay2
|
||||||
DOCKER_TLS_CERTDIR: ""
|
DOCKER_TLS_CERTDIR: ""
|
||||||
@@ -19,13 +16,13 @@ deploy:
|
|||||||
stage: deploy
|
stage: deploy
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
image: docker:20.10.16
|
image: docker:latest
|
||||||
services:
|
services:
|
||||||
- name: docker:20.10.16-dind
|
- name: docker:dind
|
||||||
alias: docker
|
alias: docker
|
||||||
script:
|
script:
|
||||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||||
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA .
|
- docker buildx build --platform linux/amd64 -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA .
|
||||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
|
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
|
||||||
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:latest
|
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:latest
|
||||||
- docker push $CI_REGISTRY_IMAGE:latest
|
- docker push $CI_REGISTRY_IMAGE:latest
|
||||||
|
|||||||
21
README.md
21
README.md
@@ -41,3 +41,24 @@ docker-compose up -d
|
|||||||
```
|
```
|
||||||
|
|
||||||
to run the container in a detatched mode.
|
to run the container in a detatched mode.
|
||||||
|
|
||||||
|
|
||||||
|
### Container
|
||||||
|
Alternatively, to deploy the app from the lastest published container:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
wmgzon:
|
||||||
|
container_name: "wmgzon"
|
||||||
|
image: lukeelse/wmgzon:latest
|
||||||
|
environment:
|
||||||
|
- FILESTORE=static/assets/img/products/
|
||||||
|
tty: true
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
volumes:
|
||||||
|
- ./files:/app/$FILESTORE
|
||||||
|
restart: unless-stopped
|
||||||
|
```
|
||||||
2
app.py
2
app.py
@@ -1,5 +1,6 @@
|
|||||||
from flask import Flask
|
from flask import Flask
|
||||||
from os import environ
|
from os import environ
|
||||||
|
from dotenv import load_dotenv
|
||||||
from controllers.web.endpoints import blueprint
|
from controllers.web.endpoints import blueprint
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@@ -11,6 +12,7 @@ from controllers.web.endpoints import blueprint
|
|||||||
app: Flask = Flask(__name__)
|
app: Flask = Flask(__name__)
|
||||||
|
|
||||||
# Set app secret key to sign session cookies
|
# Set app secret key to sign session cookies
|
||||||
|
load_dotenv()
|
||||||
secret_key = environ.get("APPSECRET")
|
secret_key = environ.get("APPSECRET")
|
||||||
if secret_key is None:
|
if secret_key is None:
|
||||||
# NO Secret Key set!
|
# NO Secret Key set!
|
||||||
|
|||||||
13
cicd/Deployment/docker-compose.yml
Normal file
13
cicd/Deployment/docker-compose.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
wmgzon:
|
||||||
|
container_name: "wmgzon"
|
||||||
|
image: lukeelse/wmgzon:latest
|
||||||
|
tty: true
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
volumes:
|
||||||
|
- ./files:/app/static/assets/img/products/
|
||||||
|
- ./data:/app/data/
|
||||||
|
restart: unless-stopped
|
||||||
@@ -5,14 +5,12 @@ services:
|
|||||||
container_name: "wmgzon"
|
container_name: "wmgzon"
|
||||||
build: .
|
build: .
|
||||||
environment:
|
environment:
|
||||||
- APPSECRET=test
|
|
||||||
- ENVIRON=test
|
- ENVIRON=test
|
||||||
#- ENVIRON=prod
|
|
||||||
- FILESTORE=static/assets/img/products/
|
|
||||||
tty: true
|
tty: true
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
|
# Dev container -> Copies complete root directory with latest
|
||||||
|
# code into the container
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
@@ -4,4 +4,5 @@ WORKDIR /app
|
|||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
COPY . /app
|
COPY . /app
|
||||||
RUN chmod +x scripts/run.bash
|
RUN chmod +x scripts/run.bash
|
||||||
CMD ["bash", "scripts/run.bash"]
|
EXPOSE 8080
|
||||||
|
ENTRYPOINT ["scripts/run.bash"]
|
||||||
@@ -24,3 +24,4 @@ virtualenv==20.24.6
|
|||||||
waitress==2.1.2
|
waitress==2.1.2
|
||||||
Werkzeug==3.0.1
|
Werkzeug==3.0.1
|
||||||
pycodestyle==2.11.1
|
pycodestyle==2.11.1
|
||||||
|
python-dotenv==1.0.1
|
||||||
@@ -1,24 +1,26 @@
|
|||||||
#! /bin/bash
|
#!/bin/bash
|
||||||
pytest --disable-warnings
|
pytest --disable-warnings
|
||||||
python ./scripts/create_database.py
|
python ./scripts/create_database.py
|
||||||
|
|
||||||
|
|
||||||
EXPECTED_VALUE="test"
|
EXPECTED_VALUE="test"
|
||||||
|
|
||||||
if [ -z "$ENVIRON" ]; then
|
if [ -z "$ENVIRON" ]; then
|
||||||
echo "ENVIRON is not set."
|
echo "ENVIRON is not set."
|
||||||
else
|
echo "Using DEFAULT Environ Value: prod"
|
||||||
echo "ENVIRON is set to: $ENVIRON"
|
|
||||||
|
|
||||||
# Trim leading and trailing whitespaces
|
export ENVIRON=prod
|
||||||
ACTUAL_VALUE=$(echo "$ENVIRON" | tr -d '[:space:]')
|
|
||||||
|
|
||||||
if [ "$ACTUAL_VALUE" = "$EXPECTED_VALUE" ]; then
|
|
||||||
echo "Launching DEV Server"
|
|
||||||
python ./app.py
|
|
||||||
else
|
|
||||||
echo "Launching PROD Server"
|
|
||||||
waitress-serve --host 0.0.0.0 app:app
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "ENVIRON is set to: $ENVIRON"
|
||||||
|
|
||||||
|
# Trim leading and trailing whitespaces
|
||||||
|
ACTUAL_VALUE=$(echo "$ENVIRON" | tr -d '[:space:]')
|
||||||
|
|
||||||
|
if [ "$ACTUAL_VALUE" = "$EXPECTED_VALUE" ]; then
|
||||||
|
echo "Launching DEV Server"
|
||||||
|
python ./app.py
|
||||||
|
else
|
||||||
|
echo "Launching PROD Server"
|
||||||
|
waitress-serve --host 0.0.0.0 app:app
|
||||||
|
fi
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
# Setup test environment variables
|
# Setup test environment variables
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
# Capture environment variables at start of testing so we can
|
# Capture environment variables at start of testing so we can
|
||||||
# Monitor current setting during tests
|
# Monitor current setting during tests
|
||||||
|
|||||||
Reference in New Issue
Block a user