Skip to content

Commit ce9c050

Browse files
Merge pull request #12 from pythonph/20180922_Issue#2_DockerEnvironment
20180922 issue#2 docker environment
2 parents bee96a0 + b720c1d commit ce9c050

File tree

7 files changed

+90
-0
lines changed

7 files changed

+90
-0
lines changed

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM ubuntu:16.04
2+
3+
RUN mkdir -p /_build/
4+
WORKDIR /_build/
5+
ADD . /_build/
6+
7+
RUN apt-get update
8+
9+
RUN apt-get install -y \
10+
sudo \
11+
build-essential \
12+
python3-dev \
13+
python3-pip \
14+
openssh-server
15+
16+
RUN make create_user
17+
18+
RUN mkdir /var/run/sshd
19+
20+
RUN rm -Rf /_build/

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SHELL := /bin/bash
2+
3+
4+
create_user:
5+
source scripts/build/create_user.sh

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#PythonPH
2+
3+
## Prerequisites
4+
* Docker
5+
* Docker Compose
6+
* Git
7+
8+
## Spinning a docker container
9+
```bash
10+
$ docker-compose -f compose/development.yml run -d --rm --name <name> --service-ports app
11+
```
12+
###### Notes:
13+
* Change `name` into what you want to call your container.
14+
* Update `development.yml` if there's conflicting with the ports.

compose/base.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: '2'
2+
3+
services:
4+
app:
5+
restart: always
6+
build:
7+
context: ../
8+
image: application
9+
volumes:
10+
- ../:/srv/src/app
11+
container_name: application
12+
working_dir: "/srv/src/app"
13+
command: scripts/docker_startup.sh

compose/development.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '2'
2+
3+
services:
4+
app:
5+
extends:
6+
file: base.yml
7+
service: app
8+
container_name: development_app
9+
ports:
10+
- "8080:8000"
11+
- "2323:22"

scripts/build/create_user.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!bin/bash
2+
SUDO_USER=happy
3+
SUDO_PASS=happy@1234
4+
APP_USER=caffeine
5+
APP_HOME=/srv/src
6+
7+
echo "==> Creating sudo user '$SUDO_USER'"
8+
sudo useradd \
9+
--user-group \
10+
--no-create-home \
11+
--shell /bin/bash \
12+
$SUDO_USER
13+
echo $SUDO_USER:$SUDO_PASS | sudo chpasswd
14+
sudo adduser $SUDO_USER sudo
15+
echo "$SUDO_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/90-$SUDO_USER
16+
17+
echo "==> Creating app user '$APP_USER'"
18+
sudo mkdir -p $APP_HOME
19+
sudo useradd \
20+
--shell /bin/bash \
21+
--user-group \
22+
--home-dir $APP_HOME \
23+
$APP_USER
24+
sudo chown $APP_USER: $APP_HOME

scripts/docker_startup.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
/usr/sbin/sshd -D

0 commit comments

Comments
 (0)