Add Alpine Dockerfile (#1048)
This commit is contained in:
parent
ac4a816a99
commit
0818384172
|
@ -0,0 +1,42 @@
|
|||
FROM alpine:3.14
|
||||
|
||||
ARG USER=drogon
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
ARG USER_HOME=/drogon
|
||||
|
||||
ENV TZ=UTC
|
||||
|
||||
RUN apk update && apk --no-cache --upgrade add tzdata \
|
||||
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
|
||||
&& echo $TZ > /etc/timezone
|
||||
|
||||
RUN apk --no-cache --upgrade add \
|
||||
sudo curl wget cmake make pkgconfig git gcc g++ \
|
||||
openssl libressl-dev jsoncpp-dev util-linux-dev zlib-dev c-ares-dev \
|
||||
postgresql-dev mariadb-dev sqlite-dev hiredis-dev
|
||||
|
||||
RUN addgroup -S -g $GID $USER \
|
||||
&& adduser -D -u $UID -G $USER -h $USER_HOME $USER \
|
||||
&& mkdir -p /etc/sudoers.d \
|
||||
&& echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER \
|
||||
&& chmod 0440 /etc/sudoers.d/$USER
|
||||
|
||||
USER $USER
|
||||
WORKDIR $USER_HOME
|
||||
|
||||
ENV LANG=en_US.UTF-8 \
|
||||
LANGUAGE=en_US:en \
|
||||
LC_ALL=en_US.UTF-8 \
|
||||
CC=gcc \
|
||||
CXX=g++ \
|
||||
AR=gcc-ar \
|
||||
RANLIB=gcc-ranlib \
|
||||
DROGON_INSTALLED_ROOT=$USER_HOME/install
|
||||
|
||||
RUN wget -O $USER_HOME/version.json https://api.github.com/repos/an-tao/drogon/git/refs/heads/master \
|
||||
&& git clone https://github.com/an-tao/drogon $DROGON_INSTALLED_ROOT
|
||||
|
||||
RUN cd $DROGON_INSTALLED_ROOT \
|
||||
&& sed -i 's/bash/sh/' ./build.sh \
|
||||
&& ./build.sh
|
|
@ -0,0 +1,32 @@
|
|||
## Build Docker Image
|
||||
|
||||
```shell
|
||||
$ cd drogon/docker/alpine # from this repository
|
||||
$ docker build --no-cache --build-arg UID=`id -u` --build-arg GID=`id -g` -t drogon-alpine . # include last dot(.)
|
||||
```
|
||||
|
||||
## Create a Drogon Project
|
||||
|
||||
```shell
|
||||
$ cd ~/drogon_app # example
|
||||
$ docker run --rm -v="$PWD:/drogon/app" -w="/drogon/app" drogon-alpine drogon_ctl create project hello_world
|
||||
```
|
||||
|
||||
## Build the Project
|
||||
|
||||
```shell
|
||||
$ cd hello_world
|
||||
$ docker run --rm --volume="$PWD:/drogon/app" -w="/drogon/app/build" drogon-alpine sh -c "cmake .. && make"
|
||||
```
|
||||
|
||||
## Start Server
|
||||
|
||||
```shell
|
||||
$ docker run --name drogon_test --rm -u 0 -v="$PWD/build:/drogon/app" -w="/drogon/app" -p 8080:80 -d drogon-alpine ./hello_world # expose port 80 to 8080
|
||||
```
|
||||
|
||||
## Stop Server
|
||||
|
||||
```shell
|
||||
$ docker kill drogon_test
|
||||
```
|
Loading…
Reference in New Issue