Skip to content

Commit 6efc446

Browse files
committed
Add docker compose and openssl config for 2.0.1 example
Signed-off-by: Lorenzo <[email protected]>
1 parent c28583f commit 6efc446

File tree

7 files changed

+122
-3
lines changed

7 files changed

+122
-3
lines changed

example/2.0.1/chargingstation/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ COPY . .
99
# Fetch dependencies.
1010
RUN go mod download
1111
# Build the binary.
12-
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /go/bin/charging_station example/2.0.1/chargingstation/*.go
12+
RUN go build -ldflags="-w -s" -o /go/bin/charging_station example/2.0.1/chargingstation/*.go
1313

1414
############################
1515
# STEP 2 build a small image
@@ -23,4 +23,4 @@ COPY --from=builder /go/bin/charging_station /bin/charging_station
2323
# Ignore the warning.
2424
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* && update-ca-certificates
2525

26-
CMD [ "charge_point" ]
26+
CMD [ "charging_station" ]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
mkdir -p certs/csms
4+
mkdir -p certs/chargingstation
5+
cd certs
6+
# Create CA
7+
openssl req -new -x509 -nodes -days 120 -extensions v3_ca -keyout ca.key -out ca.crt -subj "/CN=ocpp-go-example"
8+
# Generate self-signed CSMS certificate
9+
openssl genrsa -out csms/csms.key 4096
10+
openssl req -new -out csms/csms.csr -key csms/csms.key -config ../openssl-csms.conf -sha256
11+
openssl x509 -req -in csms/csms.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out csms/csms.crt -days 120 -extensions req_ext -extfile ../openssl-csms.conf -sha256
12+
# Generate self-signed charging-station certificate
13+
openssl genrsa -out chargingstation/charging-station.key 4096
14+
openssl req -new -out chargingstation/charging-station.csr -key chargingstation/charging-station.key -config ../openssl-chargingstation.conf -sha256
15+
openssl x509 -req -in chargingstation/charging-station.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out chargingstation/charging-station.crt -days 120 -extensions req_ext -extfile ../openssl-chargingstation.conf -sha256

example/2.0.1/csms/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ COPY . .
99
# Fetch dependencies.
1010
RUN go mod download
1111
# Build the binary.
12-
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /go/bin/csms example/2.0.1/csms/*.go
12+
RUN go build -ldflags="-w -s" -o /go/bin/csms example/2.0.1/csms/*.go
1313

1414
############################
1515
# STEP 2 build a small image

example/2.0.1/docker-compose.tls.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
version: '3'
2+
services:
3+
csms:
4+
build:
5+
context: ../..
6+
dockerfile: csms/Dockerfile
7+
image: ldonini/ocpp2.0.1-csms:latest
8+
container_name: csms
9+
volumes:
10+
- ./certs/csms:/usr/local/share/certs
11+
- ./certs/ca.crt:/usr/local/share/certs/ca.crt
12+
environment:
13+
- SERVER_LISTEN_PORT=443
14+
- TLS_ENABLED=true
15+
- CA_CERTIFICATE_PATH=/usr/local/share/certs/ca.crt
16+
- SERVER_CERTIFICATE_PATH=/usr/local/share/certs/csms.crt
17+
- SERVER_CERTIFICATE_KEY_PATH=/usr/local/share/certs/csms.key
18+
ports:
19+
- "443:443"
20+
networks:
21+
- sim
22+
tty: true
23+
charging-station:
24+
build:
25+
context: ../..
26+
dockerfile: chargingstation/Dockerfile
27+
image: ldonini/ocpp2.0.1-chargingstation:latest
28+
container_name: charging-station
29+
volumes:
30+
- ./certs/chargingstation:/usr/local/share/certs
31+
- ./certs/ca.crt:/usr/local/share/certs/ca.crt
32+
environment:
33+
- CLIENT_ID=chargingStationSim
34+
- CSMS_URL=wss://csms:443
35+
- TLS_ENABLED=true
36+
- CA_CERTIFICATE_PATH=/usr/local/share/certs/ca.crt
37+
- CLIENT_CERTIFICATE_PATH=/usr/local/share/certs/charging-station.crt
38+
- CLIENT_CERTIFICATE_KEY_PATH=/usr/local/share/certs/charging-station.key
39+
networks:
40+
- sim
41+
tty: true
42+
43+
networks:
44+
sim:
45+
driver: bridge

example/2.0.1/docker-compose.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: '3'
2+
services:
3+
csms:
4+
build:
5+
context: ../..
6+
dockerfile: csms/Dockerfile
7+
image: ldonini/ocpp2.0.1-csms:latest
8+
container_name: csms
9+
environment:
10+
- SERVER_LISTEN_PORT=8887
11+
ports:
12+
- "8887:8887"
13+
networks:
14+
- sim
15+
tty: true
16+
charging-station:
17+
build:
18+
context: ../..
19+
dockerfile: chargingstation/Dockerfile
20+
image: ldonini/ocpp2.0.1-chargingstation:latest
21+
container_name: charging-station
22+
environment:
23+
- CLIENT_ID=chargingStationSim
24+
- CSMS_URL=ws://csms:8887
25+
networks:
26+
- sim
27+
tty: true
28+
29+
networks:
30+
sim:
31+
driver: bridge
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[req]
2+
distinguished_name = req_dn
3+
req_extensions = req_ext
4+
prompt = no
5+
[req_dn]
6+
CN = charging-station
7+
[req_ext]
8+
basicConstraints = CA:FALSE
9+
subjectKeyIdentifier = hash
10+
keyUsage = digitalSignature, keyEncipherment
11+
extendedKeyUsage = clientAuth
12+
subjectAltName = @alt_names
13+
[alt_names]
14+
DNS.1 = charging-station

example/2.0.1/openssl-csms.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[req]
2+
distinguished_name = req_dn
3+
req_extensions = req_ext
4+
prompt = no
5+
[req_dn]
6+
CN = csms
7+
[req_ext]
8+
basicConstraints = CA:FALSE
9+
subjectKeyIdentifier = hash
10+
keyUsage = digitalSignature, keyEncipherment, dataEncipherment
11+
extendedKeyUsage = serverAuth
12+
subjectAltName = @alt_names
13+
[alt_names]
14+
DNS.1 = csms

0 commit comments

Comments
 (0)