Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Edb83 committed Apr 22, 2021
0 parents commit 4d2ffa8
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
core.Microsoft*
core.mongo*
core.python*
env.py
__pycache__/
*.py[cod]
node_modules/
42 changes: 42 additions & 0 deletions .gitpod.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM gitpod/workspace-full

USER root
# Setup Heroku CLI
RUN curl https://cli-assets.heroku.com/install.sh | sh

# Setup MongoDB and MySQL
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 20691eec35216c63caf66ce1656408e390cfb1f5 && \
echo "deb http://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list && \
apt-get update -y && \
touch /etc/init.d/mongod && \
apt-get -y install mongodb-org-shell -y && \
apt-get -y install links && \
apt-get install -y mysql-server && \
apt-get clean && rm -rf /var/cache/apt/* /var/lib/apt/lists/* /tmp/* && \
mkdir /var/run/mysqld && \
chown -R gitpod:gitpod /etc/mysql /var/run/mysqld /var/log/mysql /var/lib/mysql /var/lib/mysql-files /var/lib/mysql-keyring /var/lib/mysql-upgrade /home/gitpod/.cache/heroku/ && \
pip3 install flake8 flake8-flask flake8-django

# Create our own config files

COPY .vscode/mysql.cnf /etc/mysql/mysql.conf.d/mysqld.cnf

COPY .vscode/client.cnf /etc/mysql/mysql.conf.d/client.cnf

COPY .vscode/start_mysql.sh /etc/mysql/mysql-bashrc-launch.sh

USER gitpod

# Start MySQL when we log in

RUN echo ". /etc/mysql/mysql-bashrc-launch.sh" >> ~/.bashrc

# Local environment variables
# C9USER is temporary to allow the MySQL Gist to run
ENV C9_USER="gitpod"
ENV PORT="8080"
ENV IP="0.0.0.0"
ENV C9_HOSTNAME="localhost"

USER root
# Switch back to root to allow IDE to load
12 changes: 12 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
image:
file: .gitpod.dockerfile
tasks:
- init: . ${GITPOD_REPO_ROOT}/.vscode/init_tasks.sh
vscode:
extensions:
- ms-python.python
- formulahendry.auto-close-tag
- mkaufman.HTMLHint
- eventyret.bootstrap-4-cdn-snippet
- kevinglasson.cornflakes-linter
- hookyqr.beautify
10 changes: 10 additions & 0 deletions .vscode/client.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[client]
host = localhost
user = root
password =
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = root
password =
socket = /var/run/mysqld/mysqld.sock
28 changes: 28 additions & 0 deletions .vscode/init_tasks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Creates a user record for the current Cloud9 user
# Gives a personalised greeting
# Adds configuration options for SQLite
# Creates run aliases
# Author: Matt Rudge

echo "Setting the greeting"
sed -i "s/USER_NAME/$GITPOD_GIT_USER_NAME/g" ${GITPOD_REPO_ROOT}/README.md
echo "Creating the ${C9_USER} user in MySQL"
RESULT="$(mysql -sse "SELECT EXISTS(SELECT 1 FROM mysql.user WHERE user = '${C9_USER}')")"
if [ "$RESULT" = 1 ]; then
echo "${C9_USER} already exists"
else
mysql -e "CREATE USER '${C9_USER}'@'%' IDENTIFIED BY '';" -u root
echo "Granting privileges"
mysql -e "GRANT ALL PRIVILEGES ON *.* TO '${C9_USER}'@'%' WITH GRANT OPTION;" -u root
fi
echo "Creating .sqliterc file"
echo ".headers on" > ~/.sqliterc
echo ".mode column" >> ~/.sqliterc
echo "Adding run aliases"
echo 'alias run="python3 $GITPOD_REPO_ROOT/manage.py runserver 0.0.0.0:8000"' >> ~/.bashrc
echo 'alias python=python3' >> ~/.bashrc
echo 'alias pip=pip3' >> ~/.bashrc
echo "Your workspace is ready to use. Happy coding!"
source ~/.bashrc
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "internalConsole"
}
]
}
25 changes: 25 additions & 0 deletions .vscode/mysql.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
user = gitpod
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /workspace/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

key_buffer_size = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8

myisam-recover-options = BACKUP

general_log_file = /var/log/mysql/mysql.log
general_log = 1
log_error = /var/log/mysql/error.log
24 changes: 24 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.linting.pep8Enabled": false,
"python.linting.flake8Enabled": true,
"python.terminal.activateEnvironment": false,
"python.formatting.autopep8Path": "/home/gitpod/.pyenv/shims/autopep8",
"python.linting.flake8Path": "/home/gitpod/.pyenv/shims/flake8",
"cornflakes.linter.executablePath": "/home/gitpod/.pyenv/shims/flake8",
"files.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/.gitp*": true,
"**/.hg": true,
"**/.svn": true,
"**/core.Microsoft*": true,
"**/core.mongo*": true,
"**/core.python*": true,
"**/CVS": true
},
"files.autoSave": "off",
"workbench.colorTheme": "Visual Studio Dark",
"editor.defaultFormatter": "HookyQR.beautify",
}
17 changes: 17 additions & 0 deletions .vscode/start_mysql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# this script is intended to be called from .bashrc
# This is a workaround for not having something like supervisord

if [ ! -e /var/run/mysqld/gitpod-init.lock ]
then
touch /var/run/mysqld/gitpod-init.lock

# initialize database structures on disk, if needed
[ ! -d /workspace/mysql ] && mysqld --initialize-insecure

# launch database, if not running
[ ! -e /var/run/mysqld/mysqld.pid ] && mysqld --daemonize

rm /var/run/mysqld/gitpod-init.lock
fi
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
![CI logo](https://codeinstitute.s3.amazonaws.com/fullstack/ci_logo_small.png)

Welcome USER_NAME,

This is the Code Institute student template for Gitpod. We have preinstalled all of the tools you need to get started. 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 Gitpod and the extensions we use.

## Gitpod Reminders

To run a frontend (HTML, CSS, Javascript only) application in Gitpod, in the terminal, type:

`python3 -m http.server`

A blue button should appear to click: _Make Public_,

Another blue button should appear to click: _Open Browser_.

To run a backend Python file, type `python3 app.py`, if your Python file is named `app.py` of course.

A blue button should appear to click: _Make Public_,

Another blue button should appear to click: _Open Browser_.

In Gitpod 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.

## Updates Since The Instructional Video

We continually tweak and adjust this template to help give you the best experience. Here is the version history:

**October 21 2020:** Versions of the HTMLHint, Prettier, Bootstrap4 CDN and Auto Close extensions updated. The Python extension needs to stay the same version for now.

**October 08 2020:** Additional large Gitpod files (`core.mongo*` and `core.python*`) are now hidden in the Explorer, and have been added to the `.gitignore` by default.

**September 22 2020:** Gitpod occasionally creates large `core.Microsoft` files. These are now hidden in the Explorer. A `.gitignore` file has been created to make sure these files will not be committed, along with other common files.

**April 16 2020:** The template now automatically installs MySQL instead of relying on the Gitpod MySQL image. The message about a Python linter not being installed has been dealt with, and the set-up files are now hidden in the Gitpod file explorer.

**April 13 2020:** Added the _Prettier_ code beautifier extension instead of the code formatter built-in to Gitpod.

**February 2020:** The initialisation files now _do not_ auto-delete. They will remain in your project. You can safely ignore them. They just make sure that your workspace is configured correctly each time you open it. It will also prevent the Gitpod configuration popup from appearing.

**December 2019:** Added Eventyret's Bootstrap 4 extension. Type `!bscdn` in a HTML file to add the Bootstrap boilerplate. Check out the <a href="https://github.com/Eventyret/vscode-bcdn" target="_blank">README.md file at the official repo</a> for more options.

---

Happy coding!

0 comments on commit 4d2ffa8

Please sign in to comment.