Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
p0wen committed May 19, 2020
0 parents commit 10d730c
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .gitpod.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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 9DA31620334BD75D9DCB49F368818C72E52529D4 && \
echo "deb http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list && \
apt-get update -y && \
touch /etc/init.d/mongod && \
apt-get -y install mongodb-org mongodb-org-server -y && \
apt-get update -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 .theia/mysql.cnf /etc/mysql/mysql.conf.d/mysqld.cnf

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

COPY .theia/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}/.theia/init_tasks.sh
vscode:
extensions:
- [email protected]:TnGEOx35GXMhyKLjDGz9Aw==
- [email protected]:oZ/8R2VhZEhkHsoeO57hSw==
- [email protected]:TdNYbCmjW8N3yiaPW4/adg==
- [email protected]:AtNd6GnbCYVpmUkOaFXs3A==
- [email protected]:jkl8NYpF/GzsahVpjggK0Q==
- [email protected]:Sgfmpf9YWoF5/BDJu2xn0w==
10 changes: 10 additions & 0 deletions .theia/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
23 changes: 23 additions & 0 deletions .theia/init_tasks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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"
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
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 "Done"
source ~/.bashrc
14 changes: 14 additions & 0 deletions .theia/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 .theia/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
20 changes: 20 additions & 0 deletions .theia/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"python.linting.pylintEnabled": false,
"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": {
"**/.git": true,
"**/.gitp*": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/.theia": true,
},
"emmet.extensionsPath": ".theia"
}
7 changes: 7 additions & 0 deletions .theia/snippets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"html": {
"snippets": {
"form": "form>input>input:submit[value=\"Submit\"]"
}
}
}
17 changes: 17 additions & 0 deletions .theia/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
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<img src="https://codeinstitute.s3.amazonaws.com/fullstack/ci_logo_small.png" style="margin: 0;">

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.

## 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 backend lessons.

## Updates Since The Instructional Video

We continually tweak and adjust this template to help give you the best experience. Here are the updates since the original video was made:

**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 10d730c

Please sign in to comment.