bazelbuild / bazelbuild/rules_docker

Bad timezone for Marocco with @go_image_base//image

Open
#2,246 1 comment 0 reactions 0 assignees View on GitHub
Can Close?
Dominant language
Starlark
Stars
1.1k
Forks
689
PR merge metrics
No merged PRs in 30d

Description

# 🐞 bug report

### Affected Rule

The issue is caused by the rule: `go_image`

### Is this a regression?

Not regression

### Description

A clear and concise description of the problem...

I'm not really sure if its the right place to report issues related to image itself, however here this image is referenced here a lot, so I assume either you are responsible for image, or at least you can forward to however is.

Golang resolves timezones using system files. In case of `@go_image_base//image` file `/usr/share/zoneinfo/` is used, and it return wrong date. According to wikipedia Marocco changed it's DST rules in 2018: https://en.wikipedia.org/wiki/Daylight_saving_time_in_Morocco
According to https://www.timeanddate.com/time/zone/morocco/casablanca for `2023-04-26` Marocco uses UTC+01, meanwhile go program inside docker container with base as above resolves this date as UTC+00.

## 🔬 Minimal Reproduction

```go
package main

import (
"fmt"
"time"
)

func main() {
loc, err := time.LoadLocation("Africa/Casablanca")
if err != nil || loc == nil {
panic(err)
}
t, err := time.ParseInLocation("2006-01-02 15:04", "2023-04-26 22:05", loc)
if err != nil {
panic(err)
}
fmt.Printf("time: %s\n", t)
}
```

```bazel
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@io_bazel_rules_docker//container:container.bzl", "container_push")
load("@io_bazel_rules_docker//go:image.bzl", "go_image")

go_library(
name = "go_default_library",
srcs = [
"main.go",
],
importpath = "github.com/FatNinjas/SkyLane/src/scrapers/temp",
visibility = ["//visibility:private"],
)

go_binary(
name = "bin-dev",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)

go_image(
name = "dev-img",
base = "@go_image_base//image",
binary = ":bin-dev",
)

container_push(
name = "push-dev",
format = "Docker",
image = ":dev-img",
registry = "gcr.io",
repository = "my-repo/test",
tag = "latest",
)
```

When running file locally correct timezone is printed:

`2023-04-26 22:05:00 +0100 +01`

However when running it inside docker container using `base = "@go_image_base//image"` wrong timezone is printed: `2023-04-26 22:05:00 +0000 +00`

## 🔥 Exception or Error

## 🌍 Your Environment

**Operating System:**

  

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal

**Output of `bazel version`:**

  

Build label: 5.1.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Apr 8 15:49:48 2022 (1649432988)
Build timestamp: 1649432988
Build timestamp as int: 1649432988

**Rules_docker version:**

  


**Anything else relevant?**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.