-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
55 lines (42 loc) · 1.54 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
# base image
FROM --platform=linux/amd64 ubuntu:latest
# install necessary packages
RUN apt-get update && apt-get install -y \
curl \
gnupg \
lsb-release \
apt-transport-https \
ca-certificates
# add Golang offical GPG key
RUN curl -sSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
RUN apt-get install wget
RUN wget https://go.dev/dl/go1.22.1.linux-amd64.tar.gz
RUN rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.1.linux-amd64.tar.gz
# setup Golang env
ENV GOPATH /go
ENV GOROOT /usr/local/go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
# install MySQL
RUN apt-get update && apt-get install -y mysql-server && apt-get install -y mysql-client
# set up MySQL root password
ENV MYSQL_ROOT_PASSWORD 123456
COPY my.cnf /etc/mysql/mysql.conf.d/mysqld.cnf
COPY storage/migrations/db.sql /SQL
RUN mysqld_safe & until mysqladmin ping; do sleep 1; done && \
mysql -e "SOURCE /SQL;" && mysqladmin -u root password 123456
RUN service mysql restart
COPY . .
ENV GOOS linux
ENV GOARCH amd64
RUN GOOS=linux GOARCH=amd64 go build -o /usr/local/bin/snark_server ./server
RUN GOOS=linux GOARCH=amd64 go build -o /usr/local/bin/gnark_sol_caller gnark_sol_caller.go
RUN mkdir -p /app/server
RUN touch /app/server/server.log
RUN chmod a+x /usr/local/bin/snark_server
COPY start.sh /usr/local/bin/start.sh
RUN chmod a+x /usr/local/bin/start.sh
# expose mysql,server port
EXPOSE 3306 50051
CMD source /usr/local/bin/start.sh
# Set the command to be executed when the container starts
ENTRYPOINT ["/usr/local/bin/start.sh"]