-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use go modules * do not use dep for travis * Use github.com/putdotio/pas as module name * run inside docker containers * move go-mod files above to prevent download modules for each run
- Loading branch information
Showing
6 changed files
with
99 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM ubuntu:xenial | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get update && apt-get -y install mysql-server-5.7 | ||
|
||
ARG MYSQL_USER=pas | ||
ARG MYSQL_PASSWORD=123 | ||
ARG MYSQL_DATABASE=pas | ||
|
||
ADD docker-mysql-init.sh /tmp/ | ||
|
||
RUN ["bash", "/tmp/docker-mysql-init.sh"] | ||
|
||
ENTRYPOINT ["mysqld"] | ||
|
||
EXPOSE 3306 |
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,12 @@ | ||
FROM golang:1.15 | ||
|
||
WORKDIR /src | ||
COPY go.* ./ | ||
RUN go mod download | ||
|
||
COPY . ./ | ||
RUN go install | ||
|
||
ADD config.toml /etc/pas.toml | ||
|
||
ENTRYPOINT ["pas", "-config", "/etc/pas.toml"] |
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,12 @@ | ||
ListenAddress = "0.0.0.0:8080" | ||
ShutdownTimeout = 5000 | ||
MySQLDSN = "pas:123@(mysql:3306)/pas" | ||
|
||
[User] | ||
name = "string" | ||
email = "string" | ||
|
||
[Events] | ||
|
||
[Events.page_viewed] | ||
path = "string" |
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,22 @@ | ||
version: '3.2' | ||
services: | ||
mysql: | ||
image: pas-mysql | ||
container_name: pas-mysql | ||
build: | ||
dockerfile: Dockerfile-mysql | ||
context: . | ||
ports: | ||
- "3306:3306" | ||
pas: | ||
image: pas | ||
container_name: pas | ||
build: | ||
dockerfile: Dockerfile-pas | ||
context: . | ||
depends_on: | ||
- mysql | ||
ports: | ||
- "8080:8080" | ||
tty: true | ||
privileged: true |
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,36 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
mkdir /var/run/mysqld | ||
chown mysql /var/run/mysqld | ||
|
||
mysqld & | ||
pid="$!" | ||
|
||
for i in {30..0}; do | ||
if echo 'SELECT 1' | mysql &> /dev/null; then | ||
break | ||
fi | ||
echo 'MySQL init process in progress...' | ||
sleep 1 | ||
done | ||
if [ "$i" = 0 ]; then | ||
echo >&2 'MySQL init process failed.' | ||
exit 1 | ||
fi | ||
|
||
mysql -e "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;" | ||
|
||
mysql -e "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED WITH mysql_native_password BY '$MYSQL_PASSWORD' ;" | ||
mysql -e "GRANT ALL ON \`$MYSQL_DATABASE\`.* TO '$MYSQL_USER'@'%' ;" | ||
mysql -e 'FLUSH PRIVILEGES ;' | ||
|
||
if ! kill -s TERM "$pid" || ! wait "$pid"; then | ||
echo >&2 'MySQL init process failed.' | ||
exit 1 | ||
fi | ||
|
||
# listen all ips | ||
sed -i 's/^ *bind-address\s*=.*$/bind-address=0.0.0.0/' /etc/mysql/mysql.conf.d/mysqld.cnf | ||
|
||
echo MySQL init process done. Ready for start up. |
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