Skip to content

Commit d66a56c

Browse files
committed
add deploy script
1 parent 5890286 commit d66a56c

File tree

12 files changed

+93
-63
lines changed

12 files changed

+93
-63
lines changed

.github/workflows/django.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
/**/js/antibot-simulation.js
44
/**/tmp
55
.vscode
6+
docker-compose.yml
7+
entrypoint.sh
8+
prod.sh

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM python:3.9-alpine
2+
ARG DJANGO_ENV
3+
4+
ENV DJANGO_ENV=${DJANGO_ENV}
5+
# PIPENV_DOTENV_LOCATION=config/.env
6+
7+
# Creating folders, and files for a project:
8+
COPY . /code
9+
WORKDIR /code
10+
RUN apk update
11+
RUN apk add --no-cache \
12+
build-base \
13+
g++ \
14+
cairo-dev \
15+
pango-dev \
16+
nodejs \
17+
npm
18+
19+
# js install
20+
RUN npm run build --prefix /code/ticketscraping/js
21+
22+
# python install
23+
RUN pip install pipenv
24+
RUN pipenv install $(test "$DJANGO_ENV" == production || echo "--dev") --deploy --system --ignore-pipfile
25+
26+
# start the server
27+
CMD ["gunicorn", "tmtracker.wsgi:application", "-w", "4", "-b", "0.0.0.0:8080", "--log-file=/log/message.log"]

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dnspython = "*"
1010
requests = "*"
1111

1212
[dev-packages]
13+
gunicorn = "*"
1314

1415
[requires]
1516
python_version = "3.9"

Pipfile.lock

Lines changed: 24 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

buildspec.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 0.2
2+
3+
env:
4+
parameter-store:
5+
build_ssh_key: "/Dev/Production/tm-tracker-api/codebuild_ssh_key"
6+
phases:
7+
install:
8+
commands:
9+
- export DEPLOY_SCRIPT=/home/ec2-user/tm_tracker_api/prod.sh
10+
- mkdir -p ~/.ssh
11+
- echo "$build_ssh_key" > ~/.ssh/id_rsa
12+
- chmod 600 ~/.ssh/id_rsa
13+
pre_build:
14+
commands:
15+
- echo Logging into aws ECR...
16+
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
17+
build:
18+
commands:
19+
- echo Build started on `date`
20+
- echo Building the Docker image...
21+
- docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .
22+
- docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
23+
post_build:
24+
commands:
25+
- echo Build completed on `date`
26+
- echo Pushing the Docker image...
27+
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
28+
- echo Deploying the Docker image...
29+
- ssh -o "StrictHostKeyChecking no" $SERVER_URL $DEPLOY_SCRIPT
30+

install.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

secret.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
CONN_SRV = "mongodb+srv://admin:[email protected]/?retryWrites=true&w=majority"
1+
import os
2+
3+
CONN_SRV = os.environ.get('CONN_SRV')

ticketscraping/js/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "",
55
"main": "antibot-simulation.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"build": "npm ci"
89
},
910
"author": "",
1011
"license": "ISC",

0 commit comments

Comments
 (0)