├── Dockerfile ├── requirements.sh └── README.md /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM dockerhub.datacamp.com:443/msft-sql-base-prod:32 2 | #ubuntu:16.04 3 | 4 | #RUN useradd -m repl 5 | 6 | ADD requirements.sh requirements.sh 7 | 8 | RUN chmod u+x requirements.sh 9 | 10 | RUN ./requirements.sh 11 | -------------------------------------------------------------------------------- /requirements.sh: -------------------------------------------------------------------------------- 1 | # copied from https://github.com/datacamp/courses-msft-transact-sql 2 | pip3 install git+git://github.com/datacamp/sqlwhat-ext --no-deps 3 | 4 | # Follow ideas from https://github.com/datacamp/docker-msft-sql-base/blob/master/requirements.sh 5 | 6 | wget https://s3.amazonaws.com/assets.datacamp.com/production/course_5315/datasets/create-co2-database.sql 7 | 8 | ./start_server.sh 9 | 10 | # Simple task: return available tables 11 | isql Default sa $SA_PASSWORD -v < create-co2-database.sql 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # An example for debugging course images locally 2 | 3 | This repository is deisgned to assist Curriculum Leads in the Content team get started testing `requirements.sh` files for their courses on their own machines (rather than breaking the build system). 4 | 5 | ## Getting set up 6 | 7 | First, read the [main set of instructions](https://github.com/datacamp/image-management-backend/wiki/Setting-up-images) for debugging course image requirements. 8 | 9 | In particular, you need to [install docker](https://docs.docker.com/docker-for-mac/install), and ask in the `#engineering-inf` Slack channel for the credentials file to access DataCamp's Docker hub. 10 | 11 | You'll also need a text editor and the terminal. 12 | 13 | ## Creating a course image to test 14 | 15 | The course image needs two files. The names of these files are important (don't change them) and are case sensitive. 16 | 17 | - `Dockerfile` contains the instructions for Docker to build the image. 18 | - `requirements.sh` contains the instructions for installing any additional software or datasets into the image. 19 | 20 | ## `Dockerfile` contents 21 | 22 | This file should contain code like 23 | 24 | ```docker 25 | FROM dockerhub.datacamp.com:443/msft-sql-base-prod:v1.1.1 26 | ADD requirements.sh requirements.sh 27 | RUN chmod u+x requirements.sh 28 | RUN ./requirements.sh 29 | ``` 30 | 31 | Let's step through this line by line. 32 | 33 | ### `FROM dockerhub.datacamp.com:443/msft-sql-base-prod:v1.1.1` 34 | 35 | The first line says "derive this image *from* DataCamp's SQL Server base image, version `v1.1.1`". This is the only line that you want to change. 36 | 37 | The [base image](https://github.com/datacamp/base-images) that you want to derive from depends upon the technology that the course is built upon. Here are some common examples. 38 | 39 | |Tech |Image |Example FROM field | 40 | |----------|-------------------------------------------------------------------------------------|-------------------------------------------------------| 41 | |R |[r-base-prod](https://github.com/datacamp/base-images/tree/master/r-base-prod) |`FROM dockerhub.datacamp.com:443/r-base-prod:v1.0.2` | 42 | |Python |[python-base-prod](https://github.com/datacamp/base-images/tree/master/) |`FROM dockerhub.datacamp.com:443/python-base-prod:v1.1.0` | 43 | |PostgreSQL|[postgresql-base-prod](https://github.com/datacamp/base-images/tree/master/postgresql-base-prod)|`FROM dockerhub.datacamp.com:443/postgresql-base-prod:v1.1.0`| 44 | |SQL Server|[msft-sql-base-prod](https://github.com/datacamp/base-images/tree/master/msft-sql-base-prod) |`FROM dockerhub.datacamp.com:443/msft-sql-base-prod:v1.1.1` | 45 | |Shell |[shell-base-prod](https://github.com/datacamp/base-images/tree/master/shell-base-prod) |`FROM dockerhub.datacamp.com:443/shell-base-prod:v1.0.1` | 46 | 47 | You can see the latest release of each image in the "Base Images" pane of the [Content Dashboard](http://dashboards.datacamp.com/content). (Login with u: `admin`, p: `h_____a____`.) 48 | 49 | ### `ADD requirements.sh requirements.sh` 50 | 51 | The second line says "add `requirements.sh` from its current location on disk (relative to the `Dockerfile`) to a location within the image". 52 | 53 | ### `RUN chmod u+x requirements.sh` 54 | 55 | The third line says "run the chmod command to make requirements.sh executable by the user who owns it", so that Docker can run this script. 56 | 57 | ### `RUN ./requirements.sh` 58 | 59 | The fourth line says run the "requirements.sh shell script". 60 | 61 | ## `requirements.sh` contents 62 | 63 | This is where you get to experiment with doing whatever you need to do to add things to the image. Some things to bear in mind are: 64 | 65 | ### You are repl 66 | 67 | DataCamp's build process specifies that the user that is building the image is called `repl`. The current working directory is `/home/repl`. See, for example, `docker-r-base`'s [`Dockerfile`](https://github.com/datacamp/docker-r-base/blob/master/Dockerfile#L38). 68 | 69 | ### You have access to standard-issue command line tools 70 | 71 | In particular, you can download files from Amazon S3 to the image using [`wget`](https://www.gnu.org/software/wget/manual/wget.html) or [`curl`](https://curl.haxx.se/docs/manpage.html). 72 | 73 | ```sh 74 | wget https://s3.amazonaws.com/assets.datacamp.com/production/course_9999/datasets/my_data.csv 75 | ``` 76 | 77 | (Though for local testing purposes, to save you downloading datasets over and over, it's best to just put any files in the same directory as the Dockerfile.) 78 | 79 | ### You can get additional tools using apt-get or pip3 80 | 81 | If you want to install additional software, use `apt-get` (Linux package installation) or `pip`/`pip3` (Python installer). 82 | 83 | ```sh 84 | apt-get update && apt-get --yes install python-dev python-pip tar 85 | 86 | pip3 install tensorflow==1.4.0 87 | ``` 88 | 89 | ## Building the image 90 | 91 | To build the image 92 | 93 | 1. Open a terminal. 94 | 1. Navigate to the directory containing the `Dockerfile` and `requirements.sh`. 95 | 1. Run `docker build --tag datacamp/test-image .`. 96 | 97 | To explain the last command: 98 | 99 | - `docker`: Run the [Docker command line](https://docs.docker.com/engine/reference/commandline/cli) tool. 100 | - `build`: You want to [build](https://docs.docker.com/engine/reference/commandline/build) a docker image. 101 | - `--tag`: tag the image. 102 | - `datacamp/test-image`: The [tag](https://docs.docker.com/engine/reference/commandline/tag/). Change this value to something more descriptive of your course. 103 | - `.`: The directory containing your files, in this case the current directory. 104 | --------------------------------------------------------------------------------