-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit b749c77
Showing
14 changed files
with
11,112 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,54 @@ | ||
FROM ubuntu:22.04 | ||
|
||
ENV PYTHON_VERSION 3.8.12 | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
#Set of all dependencies needed for pyenv to work on Ubuntu | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends make build-essential libssl-dev libpq-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget ca-certificates curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev mecab-ipadic-utf8 git postgresql-client telnet unzip zlib1g-dev | ||
|
||
RUN curl https://cli-assets.heroku.com/install.sh | sh | ||
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs | ||
|
||
ARG USERNAME=codeany | ||
RUN useradd -ms /bin/bash $USERNAME | ||
USER $USERNAME | ||
WORKDIR /home/$USERNAME | ||
|
||
# Set-up necessary Env vars for PyEnv | ||
ENV PYENV_ROOT /home/$USERNAME/.pyenv | ||
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH | ||
|
||
# Install pyenv | ||
RUN set -ex \ | ||
&& curl https://pyenv.run | bash \ | ||
&& pyenv update \ | ||
&& pyenv install $PYTHON_VERSION \ | ||
&& pyenv global $PYTHON_VERSION \ | ||
&& pyenv rehash \ | ||
&& python3 -m pip install --no-cache-dir --upgrade pip \ | ||
&& python3 -m pip install --no-cache-dir --upgrade setuptools wheel virtualenv pipenv pylint rope flake8 mypy autopep8 pep8 pylama pydocstyle bandit notebook twine | ||
|
||
ENV PATH=$PATH:"/home/codeany/.local/bin" | ||
|
||
RUN echo 'alias python=python3' >> ~/.bashrc && \ | ||
echo 'export PIP_USER=yes' >> ~/.bashrc && \ | ||
echo 'alias pip=pip3' >> ~/.bashrc && \ | ||
echo 'alias psql="psql mydb"' >> ~/.bashrc | ||
|
||
COPY ./build-assets/heroku_config.sh /home/$USERNAME/.theia/heroku_config.sh | ||
RUN echo 'alias heroku_config=". $HOME/.theia/heroku_config.sh"' >> ~/.bashrc | ||
|
||
COPY ./build-assets/make_url.py /home/$USERNAME/.theia/make_url.py | ||
RUN echo 'alias make_url="python3 $HOME/.theia/make_url.py "' >> ~/.bashrc | ||
|
||
COPY ./build-assets/http_server.py /home/$USERNAME/.theia/http_server.py | ||
RUN echo 'alias http_server="python3 $HOME/.theia/http_server.py "' >> ~/.bashrc | ||
|
||
|
||
USER root | ||
RUN chown -R $USERNAME:$USERNAME /home/$USERNAME/.theia | ||
|
||
CMD ["tail", "-f", "/dev/null"] | ||
|
||
# Allows proxy to work for react/drf on cloud ide's | ||
ENV DANGEROUSLY_DISABLE_HOST_CHECK=true |
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,40 @@ | ||
#!/bin/bash | ||
# Script to allow Heroku API key to be pasted | ||
# exported as an environment variable | ||
# | ||
# Matt Rudge, May 2021 | ||
|
||
echo Heroku authentication configuration script | ||
echo Code Institute, 2021 | ||
echo | ||
echo Get your Heroku API key by going to https://dashboard.heroku.com | ||
echo Go to Account Settings and click on Reveal to view your Heroku API key | ||
echo | ||
|
||
if [[ -z "${HEROKU_API_KEY}" ]]; then | ||
echo Paste your Heroku API key here or press Enter to quit: | ||
read apikey | ||
if [[ -z "${apikey}" ]]; then | ||
return 0 | ||
fi | ||
echo export HEROKU_API_KEY=${apikey} >> ~/.bashrc | ||
echo Added the export. Refreshing the terminal. | ||
. ~/.bashrc > /dev/null | ||
echo Done! | ||
else | ||
echo API key is already set. | ||
echo | ||
echo To reset the API key please input "'reset'": | ||
read reset_trigger | ||
if [[ ${reset_trigger} == reset ]]; then | ||
unset HEROKU_API_KEY | ||
unset reset_trigger | ||
echo | ||
echo API key removed! | ||
else | ||
unset reset_trigger | ||
echo API key unchanged. | ||
fi | ||
echo | ||
echo Exiting | ||
fi |
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,28 @@ | ||
# Simple wrapper for http.server | ||
# to switch off caching for users | ||
# | ||
# Matt Rudge | ||
# 20th April, 2023 | ||
|
||
import http.server | ||
|
||
|
||
class NoCacheHTTPHandler(http.server.SimpleHTTPRequestHandler): | ||
def end_headers(self): | ||
""" | ||
Overrides default end_headers method | ||
""" | ||
self.send_cache_headers() | ||
http.server.SimpleHTTPRequestHandler.end_headers(self) | ||
|
||
def send_cache_headers(self): | ||
""" | ||
New method to send cache control headers | ||
""" | ||
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate") | ||
self.send_header("Pragma", "no-cache") | ||
self.send_header("Expires", "0") | ||
|
||
|
||
if __name__ == '__main__': | ||
http.server.test(HandlerClass=NoCacheHTTPHandler) |
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,14 @@ | ||
# Simple utility for creating the Cloudinary URL from a | ||
# cloudinary_python.txt file | ||
# Matt Rudge, November 2021 | ||
|
||
import re | ||
|
||
with open("cloudinary_python.txt") as f: | ||
content = f.readlines() | ||
|
||
cloud_name = re.findall(r"['](.*?)[']",content[15])[0] | ||
api_key = re.findall(r"['](.*?)[']",content[16])[0] | ||
api_secret = re.findall(r"['](.*?)[']",content[17])[0] | ||
|
||
print(f"cloudinary://{api_key}:{api_secret}@{cloud_name}") |
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,112 @@ | ||
{ | ||
"name": "Codeinstitute template", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "app", | ||
"workspaceFolder": "/workspace/template", | ||
|
||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-python.python", | ||
"formulahendry.auto-close-tag", | ||
"eventyret.bootstrap-4-cdn-snippet", | ||
"esbenp.prettier-vscode", | ||
"matt-rudge.auto-open-preview-panel", | ||
"ms-toolsai.jupyter", | ||
"ms-toolsai.jupyter-keymap", | ||
"ms-toolsai.jupyter-renderers", | ||
"bierner.markdown-preview-github-styles", | ||
"gydunhn.vsc-essentials-core" | ||
|
||
], | ||
"settings": { | ||
"files.exclude":{ | ||
"**/.git":true, | ||
"**/.svn":true, | ||
"**/.hg":true, | ||
"**/CVS":true, | ||
"**/.DS_Store":true, | ||
"**/.github":true, | ||
"**/.gitp*":true, | ||
"**/.vscode":true, | ||
"**/core.Microsoft*":true, | ||
"**/core.mongo*":true, | ||
"**/core.python*":true | ||
}, | ||
"editor.defaultFormatter":"esbenp.prettier-vscode", | ||
"python.linting.pycodestyleEnabled":true, | ||
"python.terminal.activateEnvironment":false, | ||
"workbench.iconTheme":"none", | ||
"extensions.ignoreRecommendations":true, | ||
"editor.tabCompletion":"on", | ||
"editor.showDeprecated":true, | ||
"editor.rulers":[ | ||
80 | ||
], | ||
"editor.guides.bracketPairs":"active", | ||
"editor.bracketPairColorization.independentColorPoolPerBracketType":true, | ||
"workbench.tree.expandMode":"singleClick", | ||
"workbench.tree.renderIndentGuides":"always", | ||
"workbench.tree.indent":6, | ||
"editor.formatOnType":false, | ||
"editor.formatOnSave":true, | ||
"editor.formatOnPaste":true, | ||
"[markdown]":{ | ||
"editor.defaultFormatter":"bierner.markdown-preview-github-styles" | ||
}, | ||
"[json]":{ | ||
"editor.defaultFormatter":"vscode.json-language-features" | ||
}, | ||
"[jsonc]":{ | ||
"editor.defaultFormatter":"vscode.json-language-features" | ||
}, | ||
"[xml]":{ | ||
"editor.defaultFormatter":"DotJoshJohnson.xml" | ||
}, | ||
"[javascript]":{ | ||
"editor.defaultFormatter":"vscode.typescript-language-features" | ||
}, | ||
"[typescript]":{ | ||
"editor.defaultFormatter":"vscode.typescript-language-features" | ||
}, | ||
"[css]":{ | ||
"editor.defaultFormatter":"vscode.css-language-features" | ||
}, | ||
"[less]":{ | ||
"editor.defaultFormatter":"vscode.css-language-features" | ||
}, | ||
"[scss]":{ | ||
"editor.defaultFormatter":"vscode.css-language-features" | ||
}, | ||
"[html]":{ | ||
"editor.defaultFormatter":"vscode.html-language-features" | ||
}, | ||
"javascript.format.enable":true, | ||
"javascript.format.semicolons":"insert", | ||
"javascript.preferences.quoteStyle":"single", | ||
"typescript.format.enable":true, | ||
"typescript.format.semicolons":"insert", | ||
"typescript.preferences.quoteStyle":"single", | ||
"css.hover.documentation":true, | ||
"css.lint.important":"warning", | ||
"css.lint.importStatement":"warning", | ||
"less.hover.documentation":true, | ||
"less.lint.important":"warning", | ||
"less.lint.importStatement":"warning", | ||
"scss.hover.documentation":true, | ||
"scss.lint.important":"warning", | ||
"scss.lint.importStatement":"warning", | ||
"html.hover.documentation":true, | ||
"markdownlint.config":{ | ||
"default":true, | ||
"MD001":false, | ||
"MD010":false, | ||
"MD024":false, | ||
"MD025":false | ||
} | ||
} | ||
} | ||
}, | ||
|
||
"remoteUser": "codeany" | ||
} |
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,18 @@ | ||
version: '3' | ||
services: | ||
app: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
volumes: | ||
- "/tmp/postgres/socket:/var/run/postgresql" | ||
|
||
psql: | ||
image: postgres:11.9 | ||
environment: | ||
- POSTGRES_PASSWORD=pass1234 | ||
- POSTGRES_USER=codeany | ||
- POSTGRES_DB=mydb | ||
network_mode: service:app | ||
volumes: | ||
- "/tmp/postgres/socket:/var/run/postgresql" |
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,9 @@ | ||
core.Microsoft* | ||
core.mongo* | ||
core.python* | ||
env.py | ||
__pycache__/ | ||
*.py[cod] | ||
node_modules/ | ||
.github/ | ||
cloudinary_python.txt |
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,39 @@ | ||
![CI logo](https://codeinstitute.s3.amazonaws.com/fullstack/ci_logo_small.png) | ||
|
||
Welcome, | ||
|
||
This is the Code Institute student template for Codeanywhere. We have preinstalled all of the tools you need to get started. It's perfectly ok to use this template as the basis for your project submissions. | ||
|
||
You can safely delete this README.md file, or change it for your own project. Please do read it at least once, though! It contains some important information about Codeanywhere and the extensions we use. Some of this information has been updated since the video content was created. The last update to this file was: **March 3rd, 2023** | ||
|
||
## Codeanywhere Reminders | ||
|
||
To run a frontend (HTML, CSS, Javascript only) application in Codeanywhere, in the terminal, type: | ||
|
||
`python3 -m http.server` | ||
|
||
A button should appear to click: _Open Preview_ or _Open Browser_. | ||
|
||
To run a frontend (HTML, CSS, Javascript only) application in Codeanywhere with no-cache, you can use this alias for `python3 -m http.server`. | ||
|
||
`http_server` | ||
|
||
To run a backend Python file, type `python3 app.py`, if your Python file is named `app.py` of course. | ||
|
||
A button should appear to click: _Open Preview_ or _Open Browser_. | ||
|
||
In Codeanywhere you have superuser security privileges by default. Therefore you do not need to use the `sudo` (superuser do) command in the bash terminal in any of the lessons. | ||
|
||
To log into the Heroku toolbelt CLI: | ||
|
||
1. Log in to your Heroku account and go to _Account Settings_ in the menu under your avatar. | ||
2. Scroll down to the _API Key_ and click _Reveal_ | ||
3. Copy the key | ||
4. In Codeanywhere, from the terminal, run `heroku_config` | ||
5. Paste in your API key when asked | ||
|
||
You can now use the `heroku` CLI program - try running `heroku apps` to confirm it works. This API key is unique and private to you so do not share it. If you accidentally make it public then you can create a new one with _Regenerate API Key_. | ||
|
||
--- | ||
|
||
Happy coding! |
Oops, something went wrong.