-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/docker' into development
* feature/docker: How to build and run the project with Docker in README New ENVS to configure Postgres on building docker image and using docker container Ignore some files from root user inside the docker container Added Dockerfile image from haskell:8.6.5 with dbmate and pgsql, a docker-compose with a daemon entrypoint
- Loading branch information
Showing
6 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
### APP ######################################################################## | ||
DATABASE_URL="postgres://Dandoh:[email protected]:5432/webhaskell?sslmode=disable" | ||
JWT_SECRET="my_jwt_secret" | ||
|
||
### PostgreSQL ################################################################# | ||
POSTGRES_PASSWORD="dandoh" | ||
POSTGRES_USER="Dandoh" | ||
POSTGRES_DB="webhaskell" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM haskell:8.6.5 | ||
|
||
### Install PostgreSQL | ||
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list | ||
RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - | ||
RUN apt-get update | ||
RUN apt-get -y install postgresql-11 | ||
RUN apt-get install libpq-dev | ||
|
||
ARG pg_password | ||
ARG pg_user | ||
ARG pg_db | ||
USER postgres | ||
RUN /etc/init.d/postgresql start && psql --command "CREATE USER $pg_user WITH SUPERUSER PASSWORD '$pg_password';" && createdb -O $pg_user $pg_db | ||
USER root | ||
|
||
### Install dbmate | ||
RUN curl -fsSL -o /usr/local/bin/dbmate https://github.com/amacneil/dbmate/releases/download/v1.7.0/dbmate-linux-amd64 | ||
RUN chmod +x /usr/local/bin/dbmate | ||
|
||
WORKDIR /root/ | ||
|
||
COPY ./entrypoint.sh /opt/entrypoint.sh | ||
RUN chmod +x /opt/entrypoint.sh | ||
ENTRYPOINT ["/opt/entrypoint.sh"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: '3.7' | ||
|
||
services: | ||
|
||
workspace: | ||
build: | ||
context: ./ | ||
dockerfile: Dockerfile | ||
args: | ||
pg_password: ${POSTGRES_PASSWORD} | ||
pg_user: ${POSTGRES_USER} | ||
pg_db: ${POSTGRES_DB} | ||
volumes: | ||
- ./:/root/ | ||
ports: | ||
- 8080:8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
|
||
pid=0 | ||
|
||
# SIGTERM-handler | ||
term_handler() { | ||
if [ $pid -ne 0 ]; then | ||
kill -SIGTERM "$pid" | ||
wait "$pid" | ||
fi | ||
exit 143; # 128 + 15 -- SIGTERM | ||
} | ||
|
||
# setup handlers | ||
# on callback, kill the last background process, which is `tail -f /dev/null` and execute the specified handler | ||
trap 'kill ${!}; term_handler' SIGTERM | ||
|
||
# Start PostgreSQL service | ||
/etc/init.d/postgresql start | ||
|
||
# wait forever | ||
while true | ||
do | ||
tail -f /dev/null & wait ${!} | ||
done | ||
|