Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generic platform #22

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions dockerfiles/generic/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# using ubuntu as distro which has a better set of defaults and packages
# using 20:04 as it's latest at the moment (June 2020)
# not using latest explicitly to make it future proof
FROM ubuntu:20.04

# Install locales and set UTF-8 as default locale to avoid common pitfails
# Install build-essential and openssl-dev as a minimum set of shared libs and headers
# This is effectively required to build and link any other language executable

RUN apt-get update && apt-get install -y locales \
build-essential openssl libssl-dev ca-certificates \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

questionable actually

&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.utf8

WORKDIR /source

COPY ./prepare_build.sh .
RUN /bin/bash /source/prepare_build.sh

COPY . .

# build.sh might generate `run.sh`
RUN /bin/bash /source/build.sh

# Use /bin/bash to avoid issues with +x
ENTRYPOINT ["/bin/bash", "/source/run.sh"]
22 changes: 22 additions & 0 deletions dockerfiles/generic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Customizable platform based on ubuntu:latest

## How to use generic platform:

1. Place your dependencies in `prepare_buld.sh` (you can skip it)
2. Place you build logic into `build.sh` (you can skip it)
3. Launch your code in `run.sh` (code will be located at `/source/`)


## Build algorithm:

* a single file `./prepare_buld.sh` copied under `container:/source/prepare_buld.sh`
last-g marked this conversation as resolved.
Show resolved Hide resolved
* `/source/prepare_buld.sh` is launched before the build step to setup dependencies and caches
* all code from the repository is placed under `container:/source/` folder
* `/source/buld.sh` will be called at the build step
* `/source/run.sh` will be called as an entry point for your solution

### Notes:

* `/source/run.sh` might be generated or modified by `build.sh`
* `prepare_buld.sh` must not depend on any other file in the repository
* `prepare_buld.sh` should be used for installing packages and getting extra dependencies, it should not change too frequently and required to make builds faster
16 changes: 16 additions & 0 deletions dockerfiles/generic/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e # do not proceed if we failed somewhere

# Replace contents with anything you need to do on the build step
# Here you can access internet and install additional packages with apt-get install
# You can also compile you application and place all the needed data where you expect it

# Note: if you install packages with apt-get don't forget to run
# apt-get clean && rm -rf /var/lib/apt/lists/*
# or you might end up in weird caching issues


mkdir -p /data
echo "Hello, World!" > /data/greeting.txt

22 changes: 22 additions & 0 deletions dockerfiles/generic/prepare_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e # do not proceed if we failed somewhere

# Replace contents with anything you need to do BEFORE the build step
# This is the best place to download any external dependency and install additional packages

# Note: if you install packages with apt-get don't forget to run
# `apt-get clean && rm -rf /var/lib/apt/lists/*`
# or you might end up in weird caching issues

# Note: this must be a self-contained file and should not depent on any other file in your repo

# Note: all the same can be done in build.sh, this file purely exists to speed-up build times
# and help orgamizer's team with possible cache issues
# Please be kind and move as much as possible here (and don't change it too often)


# Uncomment the following line and put some packages there
# apt-get install <something>

apt-get clean && rm -rf /var/lib/apt/lists/*
6 changes: 6 additions & 0 deletions dockerfiles/generic/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Just replace contents with
# exec $your_binary $your_extra_flags "$@"

exec /bin/echo `cat /data/greeting.txt` and "$@"