Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.5] Dockerfile optimizations #2112

Merged
merged 3 commits into from Feb 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions client/Dockerfile
Expand Up @@ -6,30 +6,34 @@
# $ docker volume create --name=dcrdex_data
#
# Run the docker image, mapping web access port.
# $ docker run -d --rm -p 127.0.0.1:5758:5758 -v dcrdex_data:/root/.dexc user/dcrdex
# $ docker run -d --rm -p 127.0.0.1:5758:5758 -v dcrdex_data:/dex/.dexc user/dcrdex
#

# frontend build
FROM node:18 AS nodebuilder
FROM node:19-buster-slim AS nodebuilder
WORKDIR /root/dex
COPY . .
RUN apt-get update && apt-get install -y git
WORKDIR /root/dex/client/webserver/site/
RUN npm clean-install
RUN npm run build

# dexc binary build
FROM golang:1.19 AS gobuilder
FROM golang:1.19-alpine AS gobuilder
COPY --from=nodebuilder /root/dex/ /root/dex/
WORKDIR /root/dex/client/cmd/dexc/
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build
WORKDIR /root/dex/client/cmd/dexcctl/
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build

# Final image
FROM alpine:3.16
WORKDIR /root
FROM debian:buster-slim
RUN apt-get update && apt-get install -y ca-certificates
WORKDIR /dex
ENV HOME /dex
RUN mkdir -p /dex/.dexc && chown 1000 /dex/.dexc
USER 1000
COPY --from=gobuilder /root/dex/client/cmd/dexc/dexc ./
COPY --from=gobuilder /root/dex/client/cmd/dexcctl/dexcctl ./
COPY --from=gobuilder /root/dex/client/webserver/site ./site
EXPOSE 5758
CMD [ "./dexc", "--webaddr=0.0.0.0:5758" ]