deoren / docker-testing

Scratch space for my efforts to learn Docker
MIT License
0 stars 0 forks source link

Create first Docker image based off of official 'ubuntu' image that builds all formats for progit2 repo #1

Closed deoren closed 6 years ago

deoren commented 6 years ago

Overview

I could follow the footsteps of others and use a smaller distro image, but I have more experience with Ubuntu and will likely find the process to be easier starting with something familiar.

TODO

Resources

deoren commented 6 years ago

ubuntu@ubuntu-devbox:~/Desktop# cat Dockerfile

FROM ubuntu

MAINTAINER deoren <deoren@users.noreply.github.com>

COPY progit2-build-script.sh /progit2-build-script.sh

#RUN /progit2-build-script.sh && /bin/bash
ENTRYPOINT /progit2-build-script.sh && /bin/bash

VOLUME /home/ubuntu/Desktop/output /output

The progit2-build-script.sh script is the same as the one mentioned in the OP.

deoren commented 6 years ago

ubuntu@ubuntu-devbox:~/Desktop# sudo docker build -t deoren/progit2:0.1 $PWD/

Sending build context to Docker daemon  13.83MB
Step 1/5 : FROM ubuntu
 ---> 0458a4468cbc
Step 2/5 : MAINTAINER deoren <docker-testing@whyaskwhy.org>
 ---> Running in fdbd1c62dd60
Removing intermediate container fdbd1c62dd60
 ---> 8a392cd6d736
Step 3/5 : COPY progit2-build-script.sh /progit2-build-script.sh
 ---> f42a05c7bbd9
Step 4/5 : ENTRYPOINT /progit2-build-script.sh && /bin/bash
 ---> Running in de0735b7861a
Removing intermediate container de0735b7861a
 ---> 52b0beab6b19
Step 5/5 : VOLUME /home/ubuntu/Desktop/output /output
 ---> Running in 6d15c78aef51
Removing intermediate container 6d15c78aef51
 ---> c0d283401eec
Successfully built c0d283401eec
Successfully tagged deoren/progit2:0.1
deoren commented 6 years ago

ubuntu@ubuntu-devbox:~/Desktop# sudo docker image ls

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
deoren/progit2      0.1                 c0d283401eec        9 minutes ago       112MB
progit2-build       latest              20aecd8c77bd        8 hours ago         795MB
ubuntu              latest              0458a4468cbc        3 days ago          112MB
bash                latest              2c3838775cf0        2 weeks ago         12.2MB
hello-world         latest              f2a91732366c        2 months ago        1.85kB

The progit2-build entry is from me saving the results of a test run earlier. I think I used sudo docker commit in some fashion to save a session (container?) with a specific name.

deoren commented 6 years ago

I ran sudo docker run -ti -v $PWD/output:/output deoren/progit2:0.1 and the image booted and ...

  1. installed required packages
  2. cloned the remote repo
  3. checked out the specified branch
  4. installed ruby gems
  5. generated formats
  6. returned a bash shell prompt

Not a bad first start. :)

deoren commented 6 years ago

Well, I spoke too soon. Looks like there was a problem generating the epub file, but that may be related to something missing in the build environment.

deoren commented 6 years ago

It's worth noting that I did not specify a version of ubuntu when I opted to use it as the base image. It defaulted to 16.04, which should be recent enough.

root@ea9f8230f83a:/progit2# lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:    16.04
Codename:   xenial
deoren commented 6 years ago

Well, I spoke too soon. Looks like there was a problem generating the epub file, but that may be related to something missing in the build environment.

I'll pursue that later. At present I have the image mostly working.

deoren commented 6 years ago

Opted to split the existing single Dockerfile + script into files for three images:

Still much tinkering to do, best practices to ignore, etc.

deoren commented 6 years ago

I have workable images for Alpine 3.7, Ubuntu 16.04 and Ubuntu 17.10. Still more to do, but they're usable in their current state. Good enough for a first try.