Dockerfile 1.55 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Dockerfile has three Arguments: base, tag, branch
# base - base image (default: debian)
# tag - tag for base mage (default: stable-slim)
# branch - user repository branch to clone (default: master)
#
# To build the image:
# $ docker build -t <dockerhub_user>/<dockerhub_repo> --build-arg arg=value .
# or using default args:
# $ docker build -t <dockerhub_user>/<dockerhub_repo> .

# set the base image. default is debian, optional ubuntu
ARG base=debian
# set the tag (e.g. latest, stable, stable-slim : for debian)
ARG tag=stable-slim

# Base image, e.g. debian:stable-slim
FROM ${base}:${tag}

LABEL maintainer='Borja Esteban'

# What branch to clone (!)
ARG branch=master

# Which user and group to use 
25
ARG user=application
26
27
ARG group=standard

BorjaEst's avatar
BorjaEst committed
28
29
30
# Set environments
ENV LANG C.UTF-8

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Install system updates and tools
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
# Install system updates and tools
        ca-certificates \
        git && \
# Clean up & back to dialog front end
    apt-get autoremove -y && \
    apt-get clean -y && \
    rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND=dialog

# Install user app:
RUN git clone --depth 1 -b ${branch} https://github.com/BorjaEst/cicd.git app && \
# Clean up
    rm -rf /root/.cache/pip/* && \
    rm -rf /tmp/*
WORKDIR /app

# Ports to expose
EXPOSE 8443
EXPOSE 8080

# Change user context and drop root privileges
RUN groupadd -r ${group} && \
    useradd --no-log-init -r -g ${group} ${user}
USER ${user}

# Start default script
ENTRYPOINT [ "/app/main" ]
CMD [ "" ]