-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (31 loc) · 980 Bytes
/
Dockerfile
File metadata and controls
48 lines (31 loc) · 980 Bytes
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
FROM ubuntu:21.10 as postgres
RUN apt-get -y update
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y postgresql
USER root
RUN apt-get install -y golang git
COPY ./ ./
RUN go mod download
RUN go build -o url_shortener ./cmd/main.go
EXPOSE 8080
EXPOSE 5432
USER postgres
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" &&\
createdb -O docker docker &&\
psql -d docker -a -f ./sql/url.sql &&\
/etc/init.d/postgresql stop
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
CMD service postgresql start && ./url_shortener -db postgres
FROM ubuntu:21.10 as redis
RUN apt-get -y update
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y redis-server
USER root
RUN apt-get install -y golang git
COPY ./ ./
RUN go mod download
RUN go build -o url_shortener ./cmd/main.go
EXPOSE 8080
EXPOSE 5379
CMD /etc/init.d/redis-server start && ./url_shortener -db redis