-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDockerfile
58 lines (41 loc) · 1.51 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
56
57
58
# github.com/gbolo/aws-power-toggle
#
# BUILD CONTAINERS ------------------------------------------------------------
#
### Building frontend
FROM debian:stable as builder-nodejs
WORKDIR /app
COPY . .
# install requirements for nvm
RUN set -xe; \
apt-get update && \
apt-get install -y --no-install-recommends ca-certificates curl bash git make
# switch to bash shell and install nvm from official script
SHELL ["/bin/bash", "--login", "-c"]
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
# install the correct nodejs version via nvm, then build the frontend
RUN nvm install && make frontend
### Building backend
FROM golang:1.14-alpine as builder-golang
WORKDIR /go/src/app
COPY . .
RUN set -xe; \
mkdir -p /tmp/build && \
apk add --no-cache git make && \
make backend && \
cp -rp testdata/sampleconfig/power-toggle-config.yaml bin/aws-power-toggle /tmp/build/
#
# FINAL BASE CONTAINER --------------------------------------------------------
#
FROM gbolo/baseos:alpine
# prepare env vars
ENV POWER_TOGGLE_SERVER_STATIC_FILES_DIR /opt/aws-pt/frontend
# prepare homedir
RUN mkdir -p /opt/aws-pt
# Copy in from builders
COPY --from=builder-golang /tmp/build/ /opt/aws-pt/
COPY --from=builder-nodejs /app/frontend/dist /opt/aws-pt/frontend
# Run as non-privileged user by default
USER 65534
# Inherit gbolo/baseos entrypoint and pass it this argument
CMD ["/opt/aws-pt/aws-power-toggle", "-config", "/opt/aws-pt/power-toggle-config.yaml"]